Skip to content

Commit 448db6d

Browse files
CopilotBrentOzar
andauthored
Fix check 71 to require user updates before cascading FK warning
Agent-Logs-Url: https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/sessions/2c84b28b-a58e-45bb-8255-01aebcbd431b Co-authored-by: BrentOzar <245462+BrentOzar@users.noreply.github.com>
1 parent 558d175 commit 448db6d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

sp_BlitzIndex.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5986,6 +5986,14 @@ BEGIN
59865986
FROM #ForeignKeys fk
59875987
WHERE ([delete_referential_action_desc] <> N'NO_ACTION'
59885988
OR [update_referential_action_desc] <> N'NO_ACTION')
5989+
AND EXISTS (
5990+
SELECT 1/0
5991+
FROM #IndexSanity i
5992+
WHERE i.object_id = fk.parent_object_id
5993+
AND i.database_id = fk.database_id
5994+
AND i.schema_name = fk.schema_name
5995+
AND i.user_updates > 0
5996+
)
59895997
OPTION ( RECOMPILE );
59905998

59915999
RAISERROR(N'check_id 72: Unindexed foreign keys.', 0,1) WITH NOWAIT;

0 commit comments

Comments
 (0)