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

 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

猜你喜欢

转载自blog.csdn.net/flon/article/details/4776278
今日推荐