Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Dynamic insert stored procedure using xml?

Author  Topic 

antrad
Starting Member

1 Post

Posted - 2009-11-17 : 11:06:19
Hello all,

I am trying to build a dynamic stored procedure using a xml data. My xml looks like,

<?xml version="1.0" encoding="utf-16"?>
<Root>
<Mode Type="Insert"></Mode>
<Entry Id="1">
<Item Column="CompanyName" DataType="nvarchar(128)" value="xx"/>
<Item Column="Name" DataType="nvarchar(256)" value="xyz"/>
<Item Column="Age" DataType="int" value="30"/>
..
..
<Entry Id="1">
</Mode>
</Root>

Can someone give me idea on how to loop through this xml and build the insert query based on the column name, datatype and the value.

Thank you.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-22 : 01:18:37
you need to use dynamic sql for this. can i ask reason for doing this from xml?
Go to Top of Page
   

- Advertisement -