您的位置:Ninedns.com->数据库

【T-SQL】清空所有表记录的存储过程

添加时间:2007-4-22 

天天用,就贴出来吧

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

相关文章
请您留言


收藏:【T-SQL】清空所有表记录的存储过程