Skip to content

Instantly share code, notes, and snippets.

@jasongaylord
Created November 16, 2012 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasongaylord/4091658 to your computer and use it in GitHub Desktop.
Save jasongaylord/4091658 to your computer and use it in GitHub Desktop.
TSQL - Delete Tables with a 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