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 |
kishoremcp
Starting Member
41 Posts |
Posted - 2013-10-04 : 10:21:16
|
hi, I have around 20 temp tables in SQL Server. How to I drop them all at a time. Temp tables are named as #temp1, #temp2, ....#temp20...Thanks in advance..RegardsKishore |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-04 : 10:31:34
|
you dont need to drop them explicitly. They will automaticaly once connection terminatesIf your attempt is to drop them within same connection you need to use something like SELECT 'DROP TABLE ' + TABLE_NAME FROM tempdb.information_schema.tables where TABLE_NAME LIKE '#temp%' then copy the result and paste on the same window and execute or add it to a variable and use dynamic sql to execute it------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2013-10-08 : 07:25:08
|
It is as simple asDrop table #temp1, #temp2, .... , #temp20MadhivananFailing to plan is Planning to fail |
![Go to Top of Page Go to Top of Page](/forums/images/icon_go_up.gif) |
|
|
|
|