Question : sqlxml to import xml data into sqlsever using store procedure

Hi,


How to use sqlxml to Convert XML data into relational data and load it into an existing SQL Server 2000 database using store procedure ? I do not want to use VB/.net/C# etc. I would just like to use store procedure for this.

Rahul

Answer : sqlxml to import xml data into sqlsever using store procedure

Hi Rahul,
You can use OPENXML to do this, Refer OPENXML in BOL. This is the example taken from BOL.
If you have a different structure, then send me the xml

DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='


   
     
     
   



   
     
   


'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT    *
FROM       OPENXML (@idoc, '/ROOT/Customer',1)
            WITH (CustomerID  varchar(10),
                  ContactName varchar(20))






Aneesh R!
Random Solutions  
 
programming4us programming4us