Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to check temp table is exist or not?

Author  Topic 

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-03-17 : 10:02:50
How do i check if temp table is exist or not, if exist then drop else create temp table.

CREATE TABLE #tbl1 (
idint,
name char(30) )

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-03-17 : 10:06:08
Here's one way:

if object_id('tempdb..#tbl1') > 0
begin
drop table #tbl1
end


Be One with the Optimizer
TG
Go to Top of Page

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-03-17 : 10:58:21
thanks TG
Go to Top of Page
   

- Advertisement -