22,210
社区成员
发帖
与我相关
我的任务
分享
--這個表沒有外鍵關聯的情況下
truncate table dbname.dbo.tb
或者
delete dbname.dbo.tb
--先禁用所有外键约束
exec sp_msforeachtable 'alter table ? nocheck CONSTRAINT all'
--然后删除数据
exec sp_msforEachTable 'TRUNCATE TABLE?'
--再启用所有外键约束
exec sp_msforeachtable 'alter table ? check constraint all'
truncate table dbname.dbo.tb
EXEC sp_msforeachtable 'truncate table ?'
Exec sp_ForEachTable "truncate table ?"