清空任何表记录的存储过程

来源:互联网 发布:云计算能干什么 编辑:程序博客网 时间:2024/06/05 04:29

use 您要清空的库
go
declare @tbname varchar(250)
declare #tb cursor for select name from sysobjects where objectproperty(id,'IsUserTable')=1
open #tb
fetch next from #tb into @tbname
while @@fetch_status=0
begin
  exec('delete from ['+@tbname+']')
  fetch next from #tb into @tbname
end
close #tb
deallocate #tb

原创粉丝点击