views:

48

answers:

2

I want to pass a table as a parameter to a stored procedure. Is it possible to do it. Please give some example.

+1  A: 

Solution to this

Convert you datable in xml by using datatable.Writexml

than pass this xml as string in stored procedure parmeter with the datatype Varchar(max)

Than use OpenXml to create datatable again form the xml string passed by you.

See the example : http://msdn.microsoft.com/en-us/library/ms186918.aspx

Pranay Rana
+5  A: 

In SQL Server 2008 you can use Table Valued Parameters - pass in a TABLE type as a parameter to a sproc.

I wrote up an article on the differences of the various approaches you could take, with a performance comparison here: CSV vs XML vs Table Valued Parameter

AdaTheDev
Thanks for the link.
vaibhav