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

Popular posts from this blog

c++ - CPP, 'X' button listener -

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -

shared memory - gstreamer shmsrc and shmsink with h264 data -