Get DB Foreign Keys
mssql_db_foreign_keysReview SQL Server foreign keys for untrusted, disabled, unindexed, or type/collation mismatch issues, suggest WITH CHECK CHECK CONSTRAINT fixes, and flag likely missing foreign keys by column name.
Instructions
Foreign keys review for one database: each foreign key with trusted, disabled, indexed (unindexed foreign keys slow joins and deletes) and column type or collation mismatches, plus the WITH CHECK CHECK CONSTRAINT fix; and likely missing foreign keys found by column name (for example Votes.PostId -> Posts.Id). Name matching is a guess, so confirm each one.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| onlyIssues | No | List only existing foreign keys that have an issue. Defaults to false (all). | |
| databaseName | No | Target database. Defaults to connected database. |