sql - TSQL to drop tables from database if they appear in lookup table -
i'd drop tables databaseone based on if marked dropping in lookuptable.
lookuptable similar below in design:
tablename droptable ========================================= tablea y tableb y tablec n tabled y
so in example, except tablec dropped.
you can try this
declare @sql nvarchar(max) = '' select @sql += n'drop table [' + name + '];' lookuptable droptable = 'y' order tablename select @sql exec sp_executesql @sql
Comments
Post a Comment