批量删除某类数据表

 1 declare @name varchar(30);
 2 declare cur cursor for 
 3     select name from sysobjects where xtype='U' and name like 'temp_%';
 4 open cur;
 5 while 1=1 begin
 6     fetch next from cur into @name;
 7     if(@@fetch_status = -1)
 8         break;
 9     exec('delete from dbo.'+@name);
10     print @name;
11 end;
12 close cur;
13 deallocate cur;

删除以"temp_"开头的数据表。

posted @ 2015-04-09 09:15  Yanyd  阅读(162)  评论(0编辑  收藏  举报