想找一个命令能清空数据库中所有用户表的方法没有找到,只能用一个比较烦琐的方法,不知道有没有更简单的方法?

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)

相关文章:

  • 2021-12-10
  • 2021-11-30
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-08-18
猜你喜欢
  • 2021-08-17
  • 2021-08-18
  • 2022-12-23
  • 2021-08-10
  • 2021-10-16
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案