Skip to content

Instantly share code, notes, and snippets.

@dcinzona
Created February 12, 2016 11:41
Show Gist options
  • Save dcinzona/f10a7de041d90d27a892 to your computer and use it in GitHub Desktop.
Save dcinzona/f10a7de041d90d27a892 to your computer and use it in GitHub Desktop.
Drop SQL Tables with Prefix
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