select @n=1
insert #temp(tablename) SELECT distinct sobjects.name
FROM sysobjects sobjects
WHERE sobjects.xtype = 'U'

select @rows = @@rowcount
while @n <= @rows
begin

	declare @tablename nvarchar(50)
	select @tablename = (select tablename from #temp where id = @n)
	--允许将显式值插入表的标识列中 ON-允许  OFF-不允许
	--exec ('set identity_insert '+@tablename+' ON')--打开
	exec ('TRUNCATE TABLE  '+@tablename)
	print(@tablename)
	select @n = @n + 1
end
go

相关文章:

  • 2021-10-26
  • 2021-06-18
  • 2021-11-13
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
相关资源
相似解决方案