Solved

where is my ##temp table

Posted on 2011-09-30
5
263 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

929 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

9 Experts available now in Live!

Get 1:1 Help Now