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 2008 Forums
 Transact-SQL (2008)
 Procedure exec in while loop

Author  Topic 

learntsql

524 Posts

Posted - 2011-12-02 : 01:04:34
Hi All,

In while loop executing procedure and that returns some reultset for every iteration.
I need to add few more columns and rows for this resultset.
What process should i folllow?
Where to store SP results and how to club columns from another resultset.
TIA.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-02 : 01:41:24
Why not add the each iteration results to a temporary table. then add a join with this temporary table in a seperate statement to combine the other columns with this resultset

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

CarlinAnderson
Starting Member

2 Posts

Posted - 2011-12-02 : 18:34:50
for the columns at least you can add dummy fillers to the inner sproc's results set so they are all consistent and drop more easily into the temp table.


select <current fields>, 0 as dummy1, '' as dummy2 from xxx
Go to Top of Page
   

- Advertisement -