Foreign Key Not Trusted - PE022 - Not for Replication
pkettley
Posts: 1 New member
The Foreign Key Not Trusted may not be taking into account the usage of "NOT FOR REPLICATION" even though the Key was altered afterwards with CHECK constraint, therefore I am assuming that the CHECK is looking at the query like the one below and not actually SCRIPTING the object and checking its CONSTRAINTS.
Please see below:
https://stackoverflow.com/questions/35892500/sql-server-foreign-key-still-not-trusted-after-check-check
SELECT '.' + '' AS TableName
,i.name AS FKName
FROM sys.foreign_keys i
INNER JOIN sys.objects o ON i.parent_object_id = o.OBJECT_ID
INNER JOIN sys.schemas s ON o.schema_id = s.schema_id
WHERE i.is_not_trusted = 1
AND i.is_not_for_replication IN (0, 1)
AND i.is_disabled = 0
Please see below:
https://stackoverflow.com/questions/35892500/sql-server-foreign-key-still-not-trusted-after-check-check
SELECT '.' + '' AS TableName
,i.name AS FKName
FROM sys.foreign_keys i
INNER JOIN sys.objects o ON i.parent_object_id = o.OBJECT_ID
INNER JOIN sys.schemas s ON o.schema_id = s.schema_id
WHERE i.is_not_trusted = 1
AND i.is_not_for_replication IN (0, 1)
AND i.is_disabled = 0