Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursors
Message
From
17/06/2011 23:05:15
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01514874
Message ID:
01515048
Views:
69
OK, I went back and tested this out.

Your original statement....If you created a temp table in SP, you can not access this temp table outside the SP was the one I didn't agree with. (And I think you now realize it wasn't completely true)

However, the .NET scenario I described actually turned out not to be relevant. Oh, well, I'm slightly closer to 50 than 40, I'm allowed a memory lapse or two. :)

But then I saw you qualify your statement, If I would change my test and call second SP from the first SP, then it will see the temp table., and that's actually what I was trying (albeit very poorly) to describe.

Here's the bottom line (and this covers your 2nd statement, as well as what Martina also replied with)....temp tables are only good for a scope/session. But the question becomes, "how far does scope/session extend?" Well, as far as the parent object wants to extend it. If you create a temp table in a "parent" object/environment, it's visible in a "child" object (like creating a temp table in proc A, and then have Proc A call Proc B, where Proc B can read the temp table)

Where it really gets tricky (and I had to do this once) is creating a temp table and then using dynamic sql, where the dynamic sql needs to access the temp table.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform