同时删除SQL server 2008中 表名类似的多个表
下面代码中的PM,表示表名以PM开头
declare @num int
select @num=COUNT(*) from sysobjects where name like 'PM%'
while(@num>0)
begin
if exists(select * from sysobjects where name like 'PM%')
declare @tb_name varchar(20),@sql varchar(100)
select @tb_name=name from sysobjects where name like 'PM%'
set @sql='drop table '+@tb_name
exec (@sql)
set @num = @num-1
end