Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 #TempTable ##TempTable difference?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

101 Posts

Posted - 03/19/2013 :  08:53:29  Show Profile  Reply with Quote

Can't seem to find the answer on google, probably searching using the incorrect terminology.

I know how #TempTable works but not used ##TempTable. - is it a sort of global temp table because of the double hash tag?


Posting Yak Master

101 Posts

Posted - 03/19/2013 :  08:59:22  Show Profile  Reply with Quote
Never mind, just found the below:

When you create a table with one hash tag (like in your example) - only connection that created it will have access to it and will automatically be deleted when the connection is closed.

If you need to ensure that all connections can see it you can use global temp table (##table) but they will also be deleted when the connection is closed so make sure you don't assume i
Go to Top of Page

Flowing Fount of Yak Knowledge

8781 Posts

Posted - 03/19/2013 :  09:00:15  Show Profile  Visit webfred's Homepage  Reply with Quote
Yes it is a global temp table.
Other sessions/users can see and use it.
It will be deleted when nobody is using it and your session is terminating.

Too old to Rock'n'Roll too young to die.
Go to Top of Page

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 03/19/2013 :  09:37:47  Show Profile  Reply with Quote
check this link.... It will give you the examples on local and global temporary tables

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000