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)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
select DB_NAME(DB_ID()), suser_sname(owner_sid) AS 'Owner'
2-
from sys.databases sdb
3-
WHERE database_id = DB_ID()
4-
go
1+
-- Get current context DB Owner
2+
select DB_NAME(DB_ID()), suser_sname(owner_sid) AS 'Owner'
3+
from sys.databases sdb
4+
WHERE database_id = DB_ID()

SQL Queries/Data Warehouse/SQL_DBSize_DW.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ sf.FILENAME AS 'Location',
2525
sf.FILEID AS 'FileId'
2626
FROM dbo.sysfiles sf WITH (NOLOCK)
2727
JOIN sys.master_files smf WITH (NOLOCK) ON smf.physical_name = sf.filename
28-
ORDER BY FileId
28+
ORDER BY FileId
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- 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.
3+
-- Blake Drumm ([email protected])
4+
USE tempdb
5+
6+
SELECT sf.NAME AS 'Name',
7+
CONCAT(convert(decimal(12,2), round(sf.size/128.000, 2)), ' MB') AS 'FileSize(MB)',
8+
CONCAT(convert(int, round(100 * convert(bigint,(sf.size-fileproperty(sf.name, 'SpaceUsed'))) / convert(bigint,sf.size), 2)),' %') AS 'FreeSpace(%)',
9+
CONCAT(convert(decimal(12,2), round((sf.size-fileproperty(sf.name, 'SpaceUsed'))/128.000, 2)), ' MB') AS 'FreeSpace(MB)',
10+
CONCAT(convert(int, 100 - (round(100 * convert(bigint,(sf.size-fileproperty(sf.name, 'SpaceUsed'))) / convert(bigint,sf.size), 2))),' %') AS 'SpaceUsed(%)',
11+
CONCAT(convert(decimal(12,2), round(fileproperty(sf.name, 'SpaceUsed')/128.000, 2)), ' MB') AS 'SpaceUsed(MB)',
12+
CASE smf.growth
13+
WHEN 0 THEN 'Disabled'
14+
ELSE 'Enabled'
15+
END AS 'AutoGrowthStatus',
16+
CASE smf.is_percent_growth
17+
WHEN 1 THEN CONCAT(CONVERT(bigint, smf.growth), ' %')
18+
ELSE CONCAT(convert(decimal(12,2), smf.growth/128),' MB')
19+
END AS 'AutoGrowth',
20+
CASE (sf.maxsize)
21+
WHEN -1 THEN 'Unlimited'
22+
WHEN 268435456 THEN 'Max Size (2TB)'
23+
ELSE CONCAT(convert(decimal(12,2), round(sf.maxsize/128.000, 2)), ' MB')
24+
END AS 'AutoGrowthMB(MAX)',
25+
sf.status,
26+
sf.FILENAME AS 'Location',
27+
sf.FILEID AS 'FileId'
28+
FROM dbo.sysfiles sf WITH (NOLOCK)
29+
JOIN sys.master_files smf WITH (NOLOCK) ON smf.physical_name = sf.filename
30+
ORDER BY FileId
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file'
1+
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file'
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
IF SERVERPROPERTY ('IsHadrEnabled') = 1
2-
BEGIN
3-
SELECT
4-
AGC.name -- Availability Group
5-
, RCS.replica_server_name -- SQL cluster node name
6-
, ARS.role_desc -- Replica Role
7-
, AGL.dns_name -- Listener Name
8-
FROM
9-
sys.availability_groups_cluster AS AGC
10-
INNER JOIN sys.dm_hadr_availability_replica_cluster_states AS RCS
11-
ON
12-
RCS.group_id = AGC.group_id
13-
INNER JOIN sys.dm_hadr_availability_replica_states AS ARS
14-
ON
15-
ARS.replica_id = RCS.replica_id
16-
INNER JOIN sys.availability_group_listeners AS AGL
17-
ON
18-
AGL.group_id = ARS.group_id
1+
IF SERVERPROPERTY ('IsHadrEnabled') = 1
2+
BEGIN
3+
SELECT
4+
AGC.name -- Availability Group
5+
, RCS.replica_server_name -- SQL cluster node name
6+
, ARS.role_desc -- Replica Role
7+
, AGL.dns_name -- Listener Name
8+
FROM
9+
sys.availability_groups_cluster AS AGC
10+
INNER JOIN sys.dm_hadr_availability_replica_cluster_states AS RCS
11+
ON
12+
RCS.group_id = AGC.group_id
13+
INNER JOIN sys.dm_hadr_availability_replica_states AS ARS
14+
ON
15+
ARS.replica_id = RCS.replica_id
16+
INNER JOIN sys.availability_group_listeners AS AGL
17+
ON
18+
AGL.group_id = ARS.group_id
1919
END

SQL Queries/Data Warehouse/SQL_Properties_DW.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SELECT CASE
1+
SELECT CASE
22
(SELECT is_broker_enabled
33
FROM sys.databases
44
WHERE name=db_name())
@@ -49,4 +49,4 @@ SELECT CASE
4949
END AS [IsFullTextInstalled],
5050
CONVERT(nvarchar(50), serverproperty('Collation')) AS COLLATION,
5151
CONVERT(nvarchar(50), serverproperty('ComputerNamePhysicalNetBIOS')) AS ComputerNamePhysicalNetBIOS,
52-
CONVERT(nvarchar(50), serverproperty('ComputerNamePhysicalNetBIOS')) AS 'SqlHost'
52+
CONVERT(nvarchar(50), serverproperty('ComputerNamePhysicalNetBIOS')) AS 'SqlHost'
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
DECLARE @DB_Users TABLE
2-
(DBName sysname, UserName sysname, LoginType sysname, AssociatedRole varchar(max),create_date datetime,modify_date datetime)
3-
4-
INSERT @DB_Users
5-
EXEC sp_MSforeachdb
6-
7-
'
8-
use [?]
9-
SELECT ''?'' AS DB_Name,
10-
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 ''##%'''
17-
18-
SELECT
19-
dbname,username ,logintype ,create_date ,modify_date ,
20-
STUFF(
21-
(
22-
SELECT ',' + CONVERT(VARCHAR(500),associatedrole)
23-
FROM @DB_Users user2
24-
WHERE
25-
user1.DBName=user2.DBName AND user1.UserName=user2.UserName
26-
FOR XML PATH('')
27-
)
28-
,1,1,'') AS Permissions_user
29-
FROM @DB_Users user1
30-
GROUP BY
31-
dbname,username ,logintype ,create_date ,modify_date
32-
ORDER BY DBName, username
1+
DECLARE @DB_Users TABLE
2+
(DBName sysname, UserName sysname, LoginType sysname, AssociatedRole varchar(max),create_date datetime,modify_date datetime)
3+
4+
INSERT @DB_Users
5+
EXEC sp_MSforeachdb
6+
7+
'
8+
use [?]
9+
SELECT ''?'' AS DB_Name,
10+
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 ''##%'''
17+
18+
SELECT
19+
dbname,username ,logintype ,create_date ,modify_date ,
20+
STUFF(
21+
(
22+
SELECT ',' + CONVERT(VARCHAR(500),associatedrole)
23+
FROM @DB_Users user2
24+
WHERE
25+
user1.DBName=user2.DBName AND user1.UserName=user2.UserName
26+
FOR XML PATH('')
27+
)
28+
,1,1,'') AS Permissions_user
29+
FROM @DB_Users user1
30+
GROUP BY
31+
dbname,username ,logintype ,create_date ,modify_date
32+
ORDER BY DBName, username

SQL Queries/OperationsManager/Alerts_ByCount.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SELECT TOP 20 SUM(1) AS AlertCount, AlertStringName, AlertStringDescription, MonitoringRuleId, Name
1+
SELECT TOP 50 SUM(1) AS AlertCount, AlertStringName, AlertStringDescription, MonitoringRuleId, Name
22
FROM Alertview WITH (NOLOCK)
33
WHERE TimeRaised is not NULL
44
GROUP BY AlertStringName, AlertStringDescription, MonitoringRuleId, Name
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
SELECT CONVERT(VARCHAR(20), TimeAdded, 102) AS DayAdded, COUNT(*) AS NumAlertsPerDay
1+
SELECT TOP 7 CONVERT(VARCHAR(20), TimeAdded, 102) AS DayAdded, COUNT(*) AS NumAlertsPerDay
22
FROM AlertView
33
WHERE TimeRaised is not NULL
44
GROUP BY CONVERT(VARCHAR(20), TimeAdded, 102)
5-
ORDER BY DayAdded DESC
5+
ORDER BY DayAdded DESC
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
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
12+
ORDER BY DaysOpened DESC, RepeatCount DESC
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
SELECT TOP 20 RepeatCount, AlertStringName, AlertStringDescription, MonitoringRuleId, Name
1+
SELECT TOP 50 RepeatCount, AlertStringName, AlertStringDescription, MonitoringRuleId, Name
22
FROM Alertview WITH (NOLOCK)
33
WHERE Timeraised is not NULL
44
GROUP BY AlertStringName, RepeatCount, AlertStringDescription, MonitoringRuleId, Name
5-
ORDER BY RepeatCount DESC
5+
ORDER BY RepeatCount DESC
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
---Check for Broken Relationship
2-
SELECT R.[RelationshipId],
3-
RT.[RelationshipTypeId],
4-
S.[FullName] as SourceName,
5-
T.[FullName] as TargetName
6-
FROM dbo.[Relationship] R with (nolock)
7-
INNER JOIN dbo.[RelationshipType] RT with (nolock)
8-
ON RT.[RelationshipTypeId] = R.[RelationshipTypeId]
9-
INNER JOIN dbo.[BaseManagedEntity] S with (nolock)
10-
ON S.[BaseManagedEntityId] = R.[SourceEntityId]
11-
INNER JOIN dbo.[BaseManagedEntity] T with (nolock)
12-
ON T.[BaseManagedEntityId] = R.[TargetEntityId]
13-
WHERE R.[IsDeleted] = 0
14-
AND (S.[IsDeleted] = 1 OR T.[IsDeleted] = 1)
1+
---Check for Broken Relationship
2+
SELECT R.[RelationshipId],
3+
RT.[RelationshipTypeId],
4+
S.[FullName] as SourceName,
5+
T.[FullName] as TargetName
6+
FROM dbo.[Relationship] R with (nolock)
7+
INNER JOIN dbo.[RelationshipType] RT with (nolock)
8+
ON RT.[RelationshipTypeId] = R.[RelationshipTypeId]
9+
INNER JOIN dbo.[BaseManagedEntity] S with (nolock)
10+
ON S.[BaseManagedEntityId] = R.[SourceEntityId]
11+
INNER JOIN dbo.[BaseManagedEntity] T with (nolock)
12+
ON T.[BaseManagedEntityId] = R.[TargetEntityId]
13+
WHERE R.[IsDeleted] = 0
14+
AND (S.[IsDeleted] = 1 OR T.[IsDeleted] = 1)

SQL Queries/OperationsManager/ConfigChurn_OpsDB.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ HAVING
3333
COUNT(*)
3434
) > 10
3535
order by
36-
[Number of changes] DESC, LanguageCode DESC
36+
[Number of changes] DESC, LanguageCode DESC
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
SELECT
2-
ManagedTypePropertyName,
3-
SettingValue,
4-
mtv.DisplayName,
5-
gs.LastModified
6-
FROM
7-
GlobalSettings gs WITH (NOLOCK)
8-
INNER JOIN ManagedTypeProperty mtp WITH (NOLOCK) on gs.ManagedTypePropertyId = mtp.ManagedTypePropertyId
9-
INNER JOIN ManagedTypeView mtv on mtp.ManagedTypeId = mtv.Id
10-
ORDER BY
1+
SELECT
2+
ManagedTypePropertyName,
3+
SettingValue,
4+
mtv.DisplayName,
5+
gs.LastModified
6+
FROM
7+
GlobalSettings gs WITH (NOLOCK)
8+
INNER JOIN ManagedTypeProperty mtp WITH (NOLOCK) on gs.ManagedTypePropertyId = mtp.ManagedTypePropertyId
9+
INNER JOIN ManagedTypeView mtv on mtp.ManagedTypeId = mtv.Id
10+
ORDER BY
1111
mtv.DisplayName

0 commit comments

Comments
 (0)