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 |
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-05-30 : 10:58:53
|
| I need to drop multiple tables in an SP... all the tables starts with a string that I can use... please suggest me the best way to drop all these tables in an SP that has more than just this.. Thanks! |
|
|
devils3cups
Starting Member
23 Posts |
Posted - 2008-05-30 : 11:11:42
|
| Can you give some clarification?When you say "all the tables starts with a string that I can use"you mean all the tables begin with the same string as in 'tbl_finance_xxxxxx"?Are you sure it needs to be a proc?I would check with someone before doing this but using a 2000 db you could try to run this commanduse master;select * from sysobjects where sysstat = '67' and name like 'tbl_finance%';to bring back a list of all the tables which have the 'starts with a string that I can use'and copy and paste it into a query statement with the statement 'drop table' before each table name.Kraig |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-30 : 12:32:23
|
| or use sp_Msforeachtable stored procedure to perform the deletion some thing likesp_Msforeachtable 'IF ? LIKE ''YourString%'' DROP TABLE ?' |
 |
|
|
|
|
|