Just to make things a bit easier for the OP.
Sample table creation script:
create table table_pattern_name_1 ( s1 varchar(20), n1 int );
create table table_pattern_name_2 ( s1 varchar(20), n1 int );
create table table_pattern_name_3 ( s1 varchar(20), n1 int );
create table table_pattern_name_4 ( s1 varchar(20), n1 int );
Table Drop script:
declare @cmd varchar(4000)
declare cmds cursor for
select 'drop table [' + Table_Name + ']'
from INFORMATION_SCHEMA.TABLES
where Table_Name like 'table_pattern_name_%'
open cmds
while 1=1
begin
fetch cmds into @cmd
if @@fetch_status != 0 break
print @cmd
exec(@cmd)
end
close cmds;
deallocate cmds
SSMS Output:
drop table [table_pattern_name_1]
drop table [table_pattern_name_2]
drop table [table_pattern_name_3]
drop table [table_pattern_name_4]
Let me know if this works for your example.
Thanks,
Matt Jones
Microsoft SQL Server