How to import below XML data into SQL Server table with three columns?
-
Try this:
DECLARE @input XML = '
SMITH
MARY
N
SMITH2
MARY2
N2
'
INSERT INTO dbo.YourTable(ColName, ColFirstName, ColOther)
SELECT
Name = XCol.value('(value)[1]','varchar(25)'),
FirstName = XCol.value('(value)[2]','varchar(25)'),
OtherValue = XCol.value('(value)[3]','varchar(25)')
FROM
@input.nodes('/dataset/data/row') AS XTbl(XCol)