Solved

where is my ##temp table

Posted on 2011-09-30
5
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

729 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