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 |
|
Wodzu
Yak Posting Veteran
58 Posts |
Posted - 2008-02-04 : 04:27:55
|
Hello folks. I am having problem with finding a temporary table.Here is an example:IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[##tmpTable]'))BEGIN DROP TABLE dbo.##tmpTableENDCREATE TABLE dbo.##tmpTable ( SomeField1 int, SomeField2 decimal(15,2) )But this doesn't seems to work (table is not dropped even if it exists). What am I doing wrong?Thanks for help. |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-02-04 : 04:37:52
|
| tryIf Object_Id('tempdb.#temptablename') is Not Null Drop table #temptablename |
 |
|
|
Wodzu
Yak Posting Veteran
58 Posts |
Posted - 2008-02-04 : 04:50:34
|
| Thanks, it works :) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-02-11 : 00:48:57
|
quote: Originally posted by sunil tryIf Object_Id('tempdb..#temptablename') is Not Null Drop table #temptablename
missing 1 dot KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|