清空数据库所有表数据
时间:2021-07-01 10:21:17
帮助过:2人阅读
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;
清空数据库所有表数据
标签: