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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop temporary table

Status
Not open for further replies.

topci

Programmer
May 6, 2005
16
SI
Hallo.

I have a little problem in MS Sql server. How cann i check when temporary table exist? I create more temp tables (create table #test_table ...) under some Sql connection; how cann i know, that this table not exist in connection?!

Please,help!

DaT
 
Simple:
Code:
if object_id('tempdb..#temptablename') is not null
begin
-- table exists
end

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Or If you want to look at all the temp tables then go to ServerName --> TempDB --> user tables in the EM.

PS: All temp tables are dropped on user session log out.

Regards,
AA

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top