清空数据库所有表数据

 1   declare c cursor for 
 2   select name from sysobjects  where xtype='u' order by name;
 3 
 4   open c;
 5   declare @t varchar(200);
 6   declare @sql varchar(max);
 7 
 8   fetch next from c into @t;
 9   while(@@FETCH_STATUS=0)
10   begin
11     set @sql='truncate table '+@t;
12     exec(@sql);
13 
14     fetch next from c into @t;
15   end;
16 
17   close c;
18   deallocate c;

 

转载于:https://www.cnblogs.com/eval/p/5386938.html

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐