I'm using Microsoft SQL Server 2008.My question is:How to drop multiple tables with common prefix in one query?
something like that table names:
LG_001_01_STLINE,
LG_001_02_STFICHE
|
I'm using Microsoft SQL Server 2008.My question is:How to drop multiple tables with common prefix in one query? something like that table names:
|
|||
|
|
|
You can build up a string using the catalog views, e.g.:
Of course there are potential gotchas, for example if these tables have foreign key relationships you'll either need to drop them first or drop the tables in a certain order. |
|||||||
|
|
I like this one that I wrote:
|
||||
|
|
|
This allows you to delete a much greater number of tables.
|
||||
|