Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Where Are the Temp Tables?

Posted on 2009-03-29
4
Medium Priority
?
713 Views
Last Modified: 2012-05-06
I've created a temp table in SQL Server, but I can't see it anywhere in Management Studio?  Where is it?
0
Comment
Question by:NigelRocks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 400 total points
ID: 24013583
it is in tempdb database.
but you might not see it there, presuming that the SSMS uses a different session that where you created the temp tables with.
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 24013703
Yeah, it's not in there.
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 600 total points
ID: 24013913
Create a temp table as
CREATE TABLE #TempTable(Col1 int)
After creating, expand the Databases -> System Databases -> tempdb -> Temporary Tables node. You will see the temp table you have created.
Once you close the session in which you have created the temp table, you can not see you temp table in the Temporary tables list in tempdb database.
0
 
LVL 51

Accepted Solution

by:
Mark Wills earned 1000 total points
ID: 24015105
as the guys above have said, temp tables are in tempdb... but only survive for the current session - they are automatically dropped.

try this little test (and maybe some handy code as well) to convince yourself. Going into SSMS and open a query window against your favourite database...

if object_id('tempdb..#test1','U') is NULL
begin
    select 'no temp test table - creating '
    create table #test1 (id int identity, column1 varchar(20))
end

insert #test1 (column1) values ('column1')     -- will insert just fine

select * from #test1

select * from tempdb.information_schema.columns where table_name like '#test1%'   -- note the 'real' table name

if object_id('tempdb..#test1','U') is NOT NULL
begin
    select 'found temp test table - dropping'
    drop table #test1                                       -- or simply finish this session
end

select * from tempdb.information_schema.columns where table_name like '#test1%'   -- not there anymore
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question