I have this xml data:<root> <DocInfo> <CompanyName>Some Company</CompanyName> <WebsiteUrl>http://www.someurl.com</WebsiteUrl> <PrimaryServices>Benefits Administration</PrimaryServices> <PrimaryServices>Payroll Processing</PrimaryServices> <SecondaryServices>Background Checking</SecondaryServices> <SecondaryServices>HR Outsourcing</SecondaryServices> </DocInfo> <DocInfo> <CompanyName>Some Company</CompanyName> <WebsiteUrl>http://www.someurl.com</WebsiteUrl> <PrimaryServices>Benefits Administration</PrimaryServices> <PrimaryServices>Payroll Processing</PrimaryServices> <SecondaryServices>Background Checking</SecondaryServices> <SecondaryServices>HR Outsourcing</SecondaryServices> </DocInfo></root>
and am using this sql to retrieve the single node values:select @xmlString = my xml stringset @xmlString = replace(@xmlString,'<?xml version="1.0" encoding="UTF-16" standalone="yes"?>','')set @XML = cast(@xmlString as xml)SelectT.N.value('CompanyName[1]', 'varchar(250)') as CompanyName,T.N.value('WebsiteUrl[1]', 'varchar(250)') as WebsiteUrl,T.N.value('PrimaryServices[1]', 'varchar(250)') as PrimaryServices,T.N.value('SecondaryServices[1]', 'varchar(250)') as SecondaryServices,T.N.value('Description[1]', 'varchar(max)') as Descriptionfrom @XML.nodes('/root/DocInfo') as T(N)
This works fine for the single node values (CompanyName, WebsiteUrl). However, it isnt inserting the nodes with multiple values properly (like PrimaryServices and SecondaryServices). How do I get the multiple node values into these columns?Thanks for any help