Skip to content

Commit 31158f1

Browse files
Push new SQL Queries 📚
1 parent 246e1bc commit 31158f1

File tree

70 files changed

+765
-699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+765
-699
lines changed

SQL Queries/Data Warehouse/DW_AggregationHistory.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ SELECT ds.DatasetDefaultName,
1111
FROM StandardDatasetAggregationHistory sdah WITH(NOLOCK)
1212
JOIN Dataset ds WITH (NOLOCK) ON sdah.DatasetId = ds.DatasetId
1313
JOIN AggregationType atype WITH (NOLOCK) ON sdah.AggregationTypeId = atype.AggregationTypeId
14-
ORDER BY StandardDatasetAggregationHistoryRowId DESC
14+
ORDER BY sdah.FirstAggregationDurationSeconds DESC
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT TOP 50 SUM(1) AS AlertCount, AlertName, AlertDescription, AlertProblemGuid, MonitorSystemName
2+
FROM Alert.vAlert va INNER JOIN
3+
Monitor mon on mon.MonitorGuid = va.AlertProblemGuid
4+
WHERE RaisedDateTime is not NULL
5+
GROUP BY AlertName, AlertDescription, AlertProblemGuid, MonitorSystemName
6+
ORDER BY AlertCount DESC
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT CONVERT(VARCHAR(20), DBCreatedDateTime, 102) AS DayAdded, COUNT(*) AS NumAlertsPerDay
2+
FROM Alert.vAlert
3+
WHERE RaisedDateTime is not NULL
4+
GROUP BY CONVERT(VARCHAR(20), DBCreatedDateTime, 102)
5+
ORDER BY DayAdded DESC
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
SELECT TOP 50 DATEDIFF(Day,RaisedDateTime,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, AlertName, AlertDescription, MonitorSystemName, MonitorGuid, ParameterValue, Case ResolutionState
6+
When 0 then 'Open'
7+
End as [ResolutionState]
8+
FROM Alert.vAlert va INNER JOIN
9+
Monitor mon on mon.MonitorGuid = va.AlertProblemGuid INNER JOIN
10+
Alert.vAlertParameter vap on va.AlertGuid = vap.AlertGuid INNER JOIN
11+
Alert.vAlertResolutionState vars on va.AlertGuid = vars.AlertGuid
12+
WHERE RaisedDateTime is not NULL
13+
AND ResolutionState = 0
14+
GROUP BY AlertName, RepeatCount, RaisedDateTime, Severity, MonitorSystemName, DWLastModifiedDateTime, AlertDescription, ParameterValue, MonitorGuid, ResolutionState
15+
ORDER BY DaysOpened DESC, RepeatCount DESC
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT TOP 50 RepeatCount, AlertName, AlertDescription, AlertProblemGuid, MonitorSystemName
2+
FROM Alert.vAlert va INNER JOIN
3+
Monitor mon on mon.MonitorGuid = va.AlertProblemGuid
4+
WHERE RaisedDateTime is not NULL
5+
GROUP BY AlertName, RepeatCount, AlertDescription, AlertProblemGuid, MonitorSystemName
6+
ORDER BY RepeatCount DESC

SQL Queries/Data Warehouse/DW_Greyed_Out_Reason_Codes.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ AS OutageDays, HSO.ReasonCode, DS.Name AS ReasonString FROM vManagedEntity AS ME
33
INNER JOIN vHealthServiceOutage AS HSO ON HSO.ManagedEntityRowId = ME.ManagedEntityRowId
44
INNER JOIN vStringResource AS SR ON HSO.ReasonCode = REPLACE(LEFT(SR.StringResourceSystemName, LEN(SR.StringResourceSystemName) - CHARINDEX('.', REVERSE(SR.StringResourceSystemName))), 'System.Availability.StateData.Reasons.', '')
55
INNER JOIN vDisplayString AS DS ON DS.ElementGuid = SR.StringResourceGuid WHERE (HSO.EndDateTime IS NULL) AND (SR.StringResourceSystemName LIKE 'System.Availability.StateData.Reasons.[0-9]%') AND DS.LanguageCode = 'ENU'
6-
ORDER BY OutageStartDateTime
6+
ORDER BY OutageStartDateTime DESC
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*Top 30 performance insertions: */
2-
select TOP 30 PR.CounterName,PR.ObjectName, vR.ruledefaultname As RuleName, COUNT(PR.countername) AS Total
3-
from Perf.vPerfRaw perf
4-
join ManagedEntity ME WITH(NOLOCK) on perf.ManagedEntityRowId = ME.ManagedEntityRowId
5-
join PerformanceRuleInstance PRI WITH(NOLOCK) on perf.PerformanceRuleInstanceRowId = PRI.PerformanceRuleInstanceRowId
6-
join PerformanceRule PR WITH(NOLOCK) on PRI.RuleRowId = PR.RuleRowId
7-
join vRule vR on vR.rulerowid = PR.RuleRowId
8-
where perf.DateTime > GetUTCDate() -48
9-
GROUP BY PR.ObjectName, PR.CounterName, vr.ruledefaultname
1+
/*Top 30 performance insertions: */
2+
select TOP 30 PR.CounterName,PR.ObjectName, vR.ruledefaultname As RuleName, COUNT(PR.countername) AS Total
3+
from Perf.vPerfRaw perf
4+
join ManagedEntity ME WITH(NOLOCK) on perf.ManagedEntityRowId = ME.ManagedEntityRowId
5+
join PerformanceRuleInstance PRI WITH(NOLOCK) on perf.PerformanceRuleInstanceRowId = PRI.PerformanceRuleInstanceRowId
6+
join PerformanceRule PR WITH(NOLOCK) on PRI.RuleRowId = PR.RuleRowId
7+
join vRule vR on vR.rulerowid = PR.RuleRowId
8+
where perf.DateTime > GetUTCDate() -48
9+
GROUP BY PR.ObjectName, PR.CounterName, vr.ruledefaultname
1010
ORDER BY COUNT (PR.CounterName) dESC
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
select r.RuleDefaultName, pr.ObjectName, pr.CounterName, mp.ManagementPackDefaultName as MPName, COUNT(me.ManagedEntityDefaultName) AS Total
2-
from Perf.vPerfRaw perf
3-
join vPerformanceRuleInstance PRI on perf.PerformanceRuleInstanceRowId = PRI.PerformanceRuleInstanceRowId
4-
join vPerformanceRule pr on PRI.RuleRowId = PR.RuleRowId
5-
join vManagedEntity me on perf.ManagedEntityRowId = ME.ManagedEntityRowId
6-
join [dbo].[vRule] r on r.RuleRowId = PR.RuleRowId
7-
join vManagementPack mp on r.ManagementPackRowId = mp.ManagementPackRowId
8-
where perf.DateTime > GetUTCDate() -48
9-
GROUP BY PR.ObjectName, PR.CounterName, r.ruledefaultname, mp.ManagementPackDefaultName
1+
select r.RuleDefaultName, pr.ObjectName, pr.CounterName, mp.ManagementPackDefaultName as MPName, COUNT(me.ManagedEntityDefaultName) AS Total
2+
from Perf.vPerfRaw perf
3+
join vPerformanceRuleInstance PRI on perf.PerformanceRuleInstanceRowId = PRI.PerformanceRuleInstanceRowId
4+
join vPerformanceRule pr on PRI.RuleRowId = PR.RuleRowId
5+
join vManagedEntity me on perf.ManagedEntityRowId = ME.ManagedEntityRowId
6+
join [dbo].[vRule] r on r.RuleRowId = PR.RuleRowId
7+
join vManagementPack mp on r.ManagementPackRowId = mp.ManagementPackRowId
8+
where perf.DateTime > GetUTCDate() -48
9+
GROUP BY PR.ObjectName, PR.CounterName, r.ruledefaultname, mp.ManagementPackDefaultName
1010
ORDER BY COUNT (me.ManagedEntityDefaultName) DESC

SQL Queries/Data Warehouse/Index_Maint_DW.sql

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
-- Get the Data Warehouse Update Rollup Version.
1+
-- Get the Data Warehouse Update Rollup Version.
22
select * from [dbo].[SqlPatchVersion] WITH (NOLOCK)

0 commit comments

Comments
 (0)