Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

temp tables, are they gone when I close that session?

Status
Not open for further replies.

daglugub37

Technical User
Oct 21, 2003
201
US
Is there anyway I can retrieve a temp table(# table) if I closed the session that created it?

Can I query the temporary database for it?
 
Hi daglubub37,

Check out the first 2 paragraphs of this article.


Yes you can query them, but best practice if you're using it in a script is to drop it anyway:

Code:
Create table #temp (enter structure)
insert #temp (enter query to populate)
select x from #temp
drop table #temp

HTH,
M.
 
Once the session that creates a temp table has closed the temp table is gone. Temp tables are session specific and are only available to the session that created them.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top