Today I found some foreign key constraints in one of our SQL Server datbases which were not trusted using the following statement:
SELECT name, is_not_trusted
FROM sys.foreign_keys
WHERE is_not_trusted = 1
I tried to fix the problem quickly using the following syntax and thought that the second check will ensure the FK is trusted again.
ALTER TABLE dbo.<TableName>
WITH CHECK CHECK CONSTRAINT <FK_NAME>
The statement completed successfully but the FK is still reported as "Not trusted". I did not find any reason therefore? Does anyone have an idea?
I already have a workaround. Dropping and Recreating the FK fixes the problem but I still wonder why the ALTER command did have no effect