想找一個指令能清空資料庫中所有使用者表的方法沒有找到,隻能用一個比較煩瑣的方法,不知道有沒有更簡單的方法?
declare @strSqlTmp varchar(8000)
declare @strSql varchar(8000)
set @strSqlTmp = ''
declare online_cursor cursor for
select 'truncate table ['+name+'];' as sql from sysobjects where type='U';
open online_cursor
fetch next from online_cursor into @strSql
while @@fetch_status=0
begin
set @strSqlTmp = @strSqlTmp + @strSql
fetch next from online_cursor into @strSql
end
close online_cursor
deallocate online_cursor
--print @strSqlTmp
exec(@strSqlTmp)