Tuesday, November 22, 2011

Reading XML into SQL Server Table -- Simple Example


Here is the simple example to read the XML data and return it as table. Use of nodes( ) and value( ) method is done.


DECLARE @xml XML
SET @xml = '
   
         
                           
                                                      
          
         
            '
SELECT T.c.value('./@id','int') as Id
     , T.c.value('./@Title','nvarchar(50)') as Title
FROM @xml.nodes('/ROOT/documents/document') T(c)


No comments:

Post a Comment