Created
February 12, 2016 11:41
-
-
Save dcinzona/f10a7de041d90d27a892 to your computer and use it in GitHub Desktop.
Drop SQL Tables with Prefix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @cmd varchar(4000) | |
declare cmds cursor for | |
select 'drop table [' + Table_Name + ']' | |
from INFORMATION_SCHEMA.TABLES | |
where Table_Name like 'prefix%' | |
open cmds | |
while 1=1 | |
begin | |
fetch cmds into @cmd | |
if @@fetch_status != 0 break | |
exec(@cmd) | |
end | |
close cmds; | |
deallocate cmds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment