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

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -