清空數據庫表腳本

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
posted @ 2011-05-21 12:18  Yaoquan.Luo  阅读(165)  评论(0编辑  收藏  举报