You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SQL Queries/Data Warehouse/DW_Greyed_Out_Reason_Codes.sql
+1-1
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,4 @@ AS OutageDays, HSO.ReasonCode, DS.Name AS ReasonString FROM vManagedEntity AS ME
3
3
INNER JOIN vHealthServiceOutage AS HSO ONHSO.ManagedEntityRowId=ME.ManagedEntityRowId
4
4
INNER JOIN vStringResource AS SR ONHSO.ReasonCode= REPLACE(LEFT(SR.StringResourceSystemName, LEN(SR.StringResourceSystemName) - CHARINDEX('.', REVERSE(SR.StringResourceSystemName))), 'System.Availability.StateData.Reasons.', '')
5
5
INNER JOIN vDisplayString AS DS ONDS.ElementGuid=SR.StringResourceGuidWHERE (HSO.EndDateTime IS NULL) AND (SR.StringResourceSystemNameLIKE'System.Availability.StateData.Reasons.[0-9]%') ANDDS.LanguageCode='ENU'
-- Modified 2/9/2022 - Included Free Space %, added MB to value fields.
2
+
-- Modified 6/21/2022 - Attempted to fix Arithmetic Overflow error when run in large environments. Added 'SpaceUsed(%)' and 'AutoGrowthStatus' columns.
case prin.name when ''dbo'' then prin.name + '' (''+ (select SUSER_SNAME(owner_sid) from master.sys.databases where name =''?'') + '')'' else prin.name end AS UserName,
11
-
prin.type_desc AS LoginType,
12
-
isnull(USER_NAME(mem.role_principal_id),'''') AS AssociatedRole ,create_date,modify_date
13
-
FROM sys.database_principals prin
14
-
LEFT OUTER JOIN sys.database_role_members mem ON prin.principal_id=mem.member_principal_id
15
-
WHERE prin.sid IS NOT NULL and prin.sid NOT IN (0x00) and
16
-
prin.is_fixed_role <> 1 AND prin.name NOT LIKE ''##%'''
case prin.name when ''dbo'' then prin.name + '' (''+ (select SUSER_SNAME(owner_sid) from master.sys.databases where name =''?'') + '')'' else prin.name end AS UserName,
11
+
prin.type_desc AS LoginType,
12
+
isnull(USER_NAME(mem.role_principal_id),'''') AS AssociatedRole ,create_date,modify_date
13
+
FROM sys.database_principals prin
14
+
LEFT OUTER JOIN sys.database_role_members mem ON prin.principal_id=mem.member_principal_id
15
+
WHERE prin.sid IS NOT NULL and prin.sid NOT IN (0x00) and
16
+
prin.is_fixed_role <> 1 AND prin.name NOT LIKE ''##%'''
SELECT TOP 20 DATEDIFF(Day,TimeRaised,current_timestamp) AS DaysOpened, Case Severity
2
-
When 0 then 'Information'
3
-
When 1 then 'Warning'
4
-
When 2 then 'Critical'
5
-
End as [Severity],RepeatCount, AlertStringName, AlertStringDescription, MonitoringObjectDisplayName, MonitoringRuleId, Name, AlertParams, Case ResolutionState
6
-
When 0 then 'Open'
7
-
End as [ResolutionState]
8
-
FROM Alertview WITH (NOLOCK)
9
-
WHERE Timeraised is not NULL
10
-
AND ResolutionState =0
11
-
GROUP BY AlertStringName, RepeatCount, TimeRaised, Severity, MonitoringObjectDisplayName, Lastmodified,AlertStringDescription, AlertParams, MonitoringRuleId, Name, ResolutionState
12
-
ORDER BY DaysOpened DESC, RepeatCount DESC
1
+
SELECT TOP 50 DATEDIFF(Day,TimeRaised,current_timestamp) AS DaysOpened, Case Severity
2
+
When 0 then 'Information'
3
+
When 1 then 'Warning'
4
+
When 2 then 'Critical'
5
+
End as [Severity],RepeatCount, AlertStringName, AlertStringDescription, MonitoringObjectDisplayName, MonitoringRuleId, Name, AlertParams, Case ResolutionState
6
+
When 0 then 'Open'
7
+
End as [ResolutionState]
8
+
FROM Alertview WITH (NOLOCK)
9
+
WHERE Timeraised is not NULL
10
+
AND ResolutionState =0
11
+
GROUP BY AlertStringName, RepeatCount, TimeRaised, Severity, MonitoringObjectDisplayName, Lastmodified,AlertStringDescription, AlertParams, MonitoringRuleId, Name, ResolutionState
0 commit comments