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.
| Author |
Topic |
|
label
Posting Yak Master
197 Posts |
Posted - 2003-04-12 : 14:31:23
|
| I just need to know how to drop a table if it exists in memory. Example. I've created a table called ##damagetemp. I access this table from several stored procs and then I drop it (theoritically) However, before I try and create the table ##damagetemp I want to check if by some chance it already exists.....So, what is the syntax to say "if my table exists then drop it"Thanks! |
|
|
Bambola
Posting Yak Master
103 Posts |
Posted - 2003-04-12 : 20:37:23
|
| if exists (select null from tempdb..sysobjects where name like '%damagetemp%') drop table ##damagetempBambola. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-04-12 : 22:58:05
|
| This also works and is a little shorter:IF OBJECT_ID('tempdb..##damagetemp')>0 DROP TABLE ##damagetemp |
 |
|
|
label
Posting Yak Master
197 Posts |
Posted - 2003-04-13 : 11:48:20
|
quote: This also works and is a little shorter:IF OBJECT_ID('tempdb..##damagetemp')>0 DROP TABLE ##damagetemp
Thank you both, that solved my issue . |
 |
|
|
|
|
|