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

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -