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.
Author |
Topic |
mike13
Posting Yak Master
219 Posts |
Posted - 2013-05-04 : 04:11:49
|
Hi,I want to run the store procedure for all the records that are returned form the selectEXEC SP_BACK_Order_checkandmove (SELECT ORDERID FROM T_Order_Main WHERE (Orderstatus = 7))Do not think this is the correct way to do this.How should i do it?Thanks a lot |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2013-05-04 : 14:16:37
|
You need to create a cursor and execute the SP for each row.-Chad |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-06 : 02:38:34
|
much better approach if its possible would be to rewrite sp to accept a list of values and then process it (there are multiple ways of doing this. refer below link)http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htmThis will make sure you just call sp once rather than inside a cursor or a loop------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|