MadGoat's Blog

导航

清空所有表的存储过程[转载]

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+']')    --exec('truncate table ['+@tbname+']')
  fetch next from #tb into @tbname
end
close #tb
deallocate #tb

posted on 2006-04-27 09:38  MadGoat  阅读(152)  评论(0编辑  收藏  举报