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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 #TempTable ##TempTable difference?

Author  Topic 

Robowski
Posting Yak Master

101 Posts

Posted - 2013-03-19 : 08:53:29
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 - 2013-03-19 : 08:59:22
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
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-03-19 : 09:00:15
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-03-19 : 09:37:47
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
   

- Advertisement -