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

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

Robowski
Posting Yak Master

101 Posts

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

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?

Cheers

Robowski
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

webfred
Flowing Fount of Yak Knowledge

Germany
8760 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

bandi
Flowing Fount of Yak Knowledge

India
2202 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
http://www.codeproject.com/Articles/42553/Quick-Overview-Temporary-Tables-in-SQL-Server-2005

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000