March 30, 2006 at 11:07 am
how do i send multiple values to an sp? say i have to insert 25 rows into a table A, instead of calling the sp 25 times can't i send 25 values to it and let it insert?
March 30, 2006 at 11:17 am
SQL stored procedure parameters do not support arrays of values natively.
That being said, you can pass a comma separated list into a stored procedure parameter defined as nvarchar(x) where x represents a reasonable lenght for the values you'll be passing in including the comma separators.
Then you can, in the body of the procedure, extract the individual values one at a time from the parameter and pass them into an insert statement that has been enclosed in a loop.
Like all things SQL there are many other alternatives that others may (hopefully) share with you.
March 30, 2006 at 1:56 pm
how do i "extract the individual values one at a time from the parameter "?
can i get an example.
thanks
April 3, 2006 at 12:12 pm
Thanks for the followup on this posting - great reference for how to do this in that other posting.
April 4, 2006 at 2:57 am
the best solution implement this is to pass xml input to stored procedure. and that is the best way. take all the data grid value and construct the xml and passito stored procedures , and look for documention on how to use xml inside the stored procedures
sp_xml_removedocument
sp_xml_preparedocument
are handy....
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply