Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cursors
Message
De
17/06/2011 23:05:15
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01514874
Message ID:
01515048
Vues:
71
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform