title: Loop through an XML to insert data in a temp table - SQL 2005
body: <p>I am trying to execute this (standalone) SQL :</p>
  
  <pre><code>Declare @test XML
  SET @test = '&lt;Products&gt;&lt;ProductId&gt;1&lt;/ProductId&gt;&lt;ProductId&gt;2&lt;/ProductId&gt;&lt;/Products&gt;'
  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)
  </code></pre>
  
  <p>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).</p>