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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Drop all Local Temporary Tables

Author  Topic 

sahu74
Posting Yak Master

100 Posts

Posted - 2006-09-11 : 13:48:04
Is here a way to drop all Local temporary tables? I am having a stored procedure that creates several Local Temporary tables. I could drop them one after the other, but was wondering if there is a way to drop them all together at the end.

Any help/suggestions will be appreciated.

Thank you.
PKS.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-09-11 : 13:54:55
You have to explicitly drop a specific table, there is no "drop all" type of statement.
If you are talking about tempdb "#" tables as opposed to permenent tables you created in the working database then do you know sql server will drop the table for you when the procedure finishes?

Be One with the Optimizer
TG
Go to Top of Page

sahu74
Posting Yak Master

100 Posts

Posted - 2006-09-11 : 14:09:01
Thank you. I was not aware that the "#" tables get dropped after the SP finishes. I was assuming that the scope is still open.

Thanks again.
PKS.


quote:
Originally posted by TG

You have to explicitly drop a specific table, there is no "drop all" type of statement.
If you are talking about tempdb "#" tables as opposed to permenent tables you created in the working database then do you know sql server will drop the table for you when the procedure finishes?

Be One with the Optimizer
TG

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-11 : 20:39:10
One of the ways is

Drop table #temp1,#temp2,etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -