不是必须转到每个子表并完全删除与您想要截断的表相关的约束,而是快速轻松地禁用任何冲突约束以允许我截断并退出没有必要做一个下降/添加哪个是combursome?
答案 0 :(得分:-1)
-- Disable all constraints including dependencies:
ALTER TABLE dbo.TableName NOCHECK CONSTRAINT ALL;
ALTER TABLE dbo.TableNamesDependencies NOCHECK CONSTRAINT ALL;
-- Truncate tables:
TRUNCATE TABLE dbo.TableName;
TRUNCATE TABLE dbo.TableNamesDependencies ;
-- Enable all constraints:
ALTER TABLE dbo.TableNamesDependencies NOCHECK CONSTRAINT ALL;
ALTER TABLE dbo.TableName CHECK CONSTRAINT ALL;