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
 When do Temp tabled expire (SQL 2008R2)?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Eagle_f90
Constraint Violating Yak Guru

USA
422 Posts

Posted - 10/03/2012 :  19:58:41  Show Profile  Visit Eagle_f90's Homepage  Reply with Quote
In 2008R2 if I create #Temp in a query or proc when does that table drop it's self or do I need to remember to call the drop command at the end of my work?

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

sql-programmers
Posting Yak Master

USA
190 Posts

Posted - 10/04/2012 :  00:30:20  Show Profile  Visit sql-programmers's Homepage  Reply with Quote
Hi Eagle,

You dont need to drop that temp table. It will be dropped automatically when when once all connections have been closed.

Please refer this article to know about temp tables.

http://www.codeproject.com/Articles/42553/Quick-Overview-Temporary-Tables-in-SQL-Server-2005

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 10/04/2012 :  00:37:02  Show Profile  Reply with Quote
quote:
Originally posted by sql-programmers

Hi Eagle,

You dont need to drop that temp table. It will be dropped automatically when when once all connections have been closed.

Please refer this article to know about temp tables.

http://www.codeproject.com/Articles/42553/Quick-Overview-Temporary-Tables-in-SQL-Server-2005

SQL Server Programmers and Consultants
http://www.sql-programmers.com/


thats for ## tables (global temporary tables)
# table gets destroyed once connection that created it terminates. Also you can have # tables with same name in multiple connections simultaneously

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17584 Posts

Posted - 10/04/2012 :  00:48:59  Show Profile  Reply with Quote
for # table, it is created inside a stored procedure, it is destroyed when the stored procedure terminates even if the connection / session is still alive.


KH
Time is always against us

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