{"name":"Server principals with default database offline","description":"The metric cross-checks sys.server_principals with the sys.databases and returns a count of the server principals that have their default database offline.\r\n\r\nCheck the results of this and resolve the issues:\r\n\r\nSELECT  [sp].[name] AS [server principle] ,\r\n        [sp].[default_database_name] ,\r\n        [sp].[principal_id] ,\r\n        [sp].[sid] ,\r\n        [sp].[type] ,\r\n        [sp].[type_desc] ,\r\n        [sp].[is_disabled]\r\nFROM    [sys].[server_principals] AS sp\r\n        INNER JOIN sys.databases AS d ON [sp].[default_database_name] = d.[name]\r\nWHERE   [d].[state_desc] <> 'online'\r\nORDER BY [sp].[default_database_name] ,\r\n        [sp].[name];\r\n","tsql":"DECLARE @Users INT;\r\n\r\nSELECT @Users = COUNT(*)\r\n  FROM [sys].[server_principals] AS sp \r\n  INNER JOIN sys.databases AS d\r\n  ON\r\n    [sp].[default_database_name] = d.[name]\r\n  WHERE [d].[state_desc] <> 'online';\r\n  \r\nSELECT ISNULL(@Users, 0);\r\n","instances":false,"frequency":1800,"databases":{"mode":1},"rateofchange":false,"metricenabled":true,"alertname":"Server principals with default database offline","alertdescription":"There are server principals that will get a connection error when not specifying a database in a connection string. Set the default database to a database that is online.","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":false},"_thresholds_medium":{"selected":true,"value":1},"_thresholds_low":{"selected":false},"thresholds_comment":"Note: These thresholds are intended as guideline values. If they seem too high or too low for your environment, replace them with values more suited to your server performance.","targetentitytype":0}