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 |
actuary
Starting Member
23 Posts |
Posted - 2006-10-12 : 05:30:46
|
Hi,I am trying to return results from an existing stored procedure in a cursor. Its something like:declare Tmp_Cursor cursor for (exec testsp)I am not sure if this is correct as its erroring out near the "for" statement. I would appreciate any help.Cheers! |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-12 : 05:33:38
|
insert the result from the SP into a temporary table.create your cursor against that temporary table.Peter LarssonHelsingborg, Sweden |
 |
|
actuary
Starting Member
23 Posts |
Posted - 2006-10-12 : 06:06:38
|
Hi, the tstsp actually is creating a temporary table which then runs the select query. Would this temporary table (created in the first procedure) be visible to the second stored procedure if it calls it? |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-10-12 : 08:18:14
|
If the parent SP creates temp table, it is accessible to all the nested SPs it calles!SP1 -> creates temp table |-------------------| | |Sp2 Sp3 Sp4|________|_________| (available here) but temp table created by child SPs (Sp2, Sp3 or Sp4) is not accessible to parent SP (Sp1)Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-12 : 08:23:52
|
It is called SCOPE.Or you can add a global temp table with ## (double #) prefix.Peter LarssonHelsingborg, Sweden |
 |
|
actuary
Starting Member
23 Posts |
Posted - 2006-10-12 : 08:59:23
|
Thanks for the help guys, much appreciated! |
 |
|
|
|
|