使用游标逐个清空表
declare tempCursor cursor for
select name from sysobjects where type='U'--获取数据库中所有表名:‘U’表示用户表
open tempCursor
declare @tbName varchar(50)
fetch next from tempCursor
into @tbName
while @@fetch_status=0
begin
exec('truncate table '+ @tbName )
fetch next from tempCursor
into @tbName
end
close tempCursor
deallocate tempCursor
go