{"name":"Untrusted foreign keys","description":"The number of foreign keys that have their is_not_trusted flag set to 1 in the sys.foreign_keys table.\r\n\r\nIf foreign keys exist, find out which ones they are by running:\r\n<pre class=sql>SELECT * FROM sys.foreign_keys WHERE is_not_trusted = 1 AND is_not_for_replication = 0<\/pre>\r\n\r\nFor details of how to fix them, see <a href:\/\/http:\/\/www.brentozar.com\/blitz\/foreign-key-trusted\/>Brent Ozar's article: Blitz Result: Foreign Keys or Check Constraints Not Trusted<\/a>.\r\n","tsql":"\/*get the current database name*\/\r\nDECLARE @DBName VARCHAR(500)\r\nSELECT @DBName = DB_NAME()\r\n\r\n\/*set the tsql to be executed in a variable as it need to be combined with the @DBName variable *\/\r\nDECLARE @strSQL VARCHAR(200)\r\nSET @strSQL = 'SELECT COUNT(*) FROM [' + @DBName + '].sys.foreign_keys WHERE is_not_trusted = 1 AND is_not_for_replication = 0'\r\n\r\n\/*execute the tsql*\/\r\nEXEC (@strSQL)\r\n","instances":true,"frequency":86400,"databases":{"mode":0},"rateofchange":false,"metricenabled":true,"alertname":"Untrusted foreign keys","alertdescription":"This alert is raised when the number of foreign keys detected exceeds the thresholds set.\r\n\r\nIf foreign keys exist, find out which ones they are by running:\r\n<pre class=sql>SELECT * FROM sys.foreign_keys WHERE is_not_trusted = 1 AND is_not_for_replication = 0<\/pre>\r\n\r\nFor details of how to fix them, see <a href:\/\/http:\/\/www.brentozar.com\/blitz\/foreign-key-trusted\/>Brent Ozar's article: Blitz Result: Foreign Keys or Check Constraints Not Trusted<\/a>.\r\n","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":0},"_thresholds_medium":{"selected":false},"_thresholds_low":{"selected":false},"thresholds_comment":"Note: These threshold settings are intended as guideline values. You may consider replacing them with values more suited to your environment.","targetentitytype":0}