Solved

Where Are the Temp Tables?

Posted on 2009-03-29
4
707 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 100 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 150 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 250 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

695 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