游历数据库内所有名字符合条件的表

来源:互联网 发布:中国综合社会调查数据 编辑:程序博客网 时间:2024/05/10 13:18

 declare  @cur varchar(50)
declare curname  cursor
for
select name  from test.dbo.sysobjects where name like 'web_supply_%' or name like'sj_%'
open  curname
fetch next from curname into @cur
while @@fetch_status=0
begin
declare @strSql varchar(500)
set @strSql='drop table '+ @cur
exec( @strSql)
fetch next from curname into @cur
end
close curname
deallocate curname

原创粉丝点击