批量删除某类数据表
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_"开头的数据表。