December 10, 2010 at 6:48 am
I used code below to drop temp table:
IF OBJECT_ID(N'tempdb..[#temp1]', N'U') IS NOT NULL
DROP TABLE [#temp1]
But in a query, there are about 15 temp table.
How to code to drop all temp tables one time without going through all temp tables' name?
December 10, 2010 at 6:51 am
Are you writing a stored procedure?
If so, you don't need to explicitly drop the temp tables. The whole point is that they'll go away when the connection closes at the end of the proc.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 10, 2010 at 6:53 am
No, in query window
December 10, 2010 at 6:55 am
Then you'll need to drop them explicitly.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 10, 2010 at 7:00 am
Use @table vars
December 10, 2010 at 7:08 am
GSquared (12/10/2010)
Then you'll need to drop them explicitly.
Well you could always reboot the server between runs :hehe:.
Pls don't try this at home folks!
December 13, 2010 at 7:15 am
nzrdb6 (12/10/2010)
Use @table vars
But only if you understand the performance and transactional differences between the two.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply