Solved

where is my ##temp table

Posted on 2011-09-30
5
260 Views
Last Modified: 2012-06-21
I have a proc which creats ##tempb but does not drop it until the next execution. my question is does SSMS keep that table in the  TABLE view or someplace else. Even after a refresh i dot see it in the list view but I knows it's still there because i can select off it
0
Comment
Question by:rschmehl
  • 2
  • 2
5 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 25 total points
ID: 36892670
The table you have is a global temporary table and is stored in tempdb.

For a session based temporary table, use a single # rather than ##
0
 
LVL 2

Assisted Solution

by:akku101
akku101 earned 25 total points
ID: 36892716
This gloabal temp table is stored in TempDB and will be accessable from the session created, It will be better if you Include drop statement at the end of the SP to avoid Tempdb to grow unnecessarly.
0
 
LVL 2

Expert Comment

by:akku101
ID: 36892741
Sorry, global temp table is accessable for other sessions aswell.
0
 

Author Closing Comment

by:rschmehl
ID: 36892766
I found it.  I was looking in the DB table view and should have been looking at the view which has the master etc  tempdb    thanks
for the help
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 36892770
That's correct. A global table is available to all sessions. A session table (#tempb) is only available for that session.

For good housekeeping in code if you have finished with a temporary table, drop it. Don't leave it for SQL to deal with. Bad practice. Also, consider using table variables rather than temporary tables wher you can. The performance benefit is worth it. They can do almost everything that a temporary and real table can do. They aren't written to disk and are destroyed at the end of the session from memory.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now