I am trying to execute this (standalone) SQL :
Declare @test XML
SET @test = '<Products><ProductId>1</ProductId><ProductId>2</ProductId></Products>'
DECLARE @Temp TABLE(
ProductId NVARCHAR(10)
)
INSERT INTO @Temp(ProductId)
SELECT tab.col.value('./ProductId[1]','NVARCHAR(10)') AS 'ProductId'
FROM @test
CROSS APPLY
xml_data.nodes('//Products') AS tab(col)
It seems I require to create a Table instead of using Temp Table, Is there a way to loop through the XMl nodes and insert them into a Temp table (without using Cursors).