"Deletes are not allowed as it will invalidate the Meta Vaut AuditLog" SQL 服务器

"Deletes are not allowed as it will invalidate the Meta Vaut AuditLog" SQL Server

use DatabaseExample
go

DELETE FROM schema1.table1;
DELETE FROM schema2.table2;
DELETE FROM schema3.table3;

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

我已经更改了 tables/databases 的名称,因为我不想冒险分享敏感信息。但是,每当我尝试从 SCHEMA2 中删除 table 时,它都会给我以下消息:

Msg 50000, Level 16, State 1, Procedure tdel_Batches, Line 21
Deletes are not allowed as it will invalidate the Meta Vault AuditLog. You can disable the trigger at your own risk.

Msg 3609, Level 16, State 1, Line 11
The transaction ended in the trigger. The batch has been aborted.

我尝试禁用整个服务器的触发器,但没有任何效果。就像我说的,它只是特定模式中的 tables,其他都很好。这两个存储过程是禁用任何键约束,然后在我完成后重新启用它们。

错误似乎在触发器中,因此您应该尝试在要从中删除数据的表中禁用它们:

sp_msforeachtable 'ALTER TABLE ? DISABLE TRIGGER all';

如果以后想再次启用它们,可以这样做;

sp_msforeachtable 'ALTER TABLE ? ENABLE TRIGGER all';