Skip to content

Commit e386bf4

Browse files
authored
Merge pull request #3687 from JamesDavis-Aviagen/James2
Added @UsualOwnerOfJobs to be used in CheckID 6 Jobs Owned By Users
2 parents 2679bc0 + 9ad7306 commit e386bf4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sp_Blitz.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ALTER PROCEDURE [dbo].[sp_Blitz]
2626
@SummaryMode TINYINT = 0 ,
2727
@BringThePain TINYINT = 0 ,
2828
@UsualDBOwner sysname = NULL ,
29+
@UsualOwnerOfJobs sysname = NULL , -- This is to set the owner of Jobs is you have a different account than SA that you use as Default
2930
@SkipBlockingChecks TINYINT = 1 ,
3031
@Debug TINYINT = 0 ,
3132
@Version VARCHAR(30) = NULL OUTPUT,
@@ -1937,7 +1938,11 @@ AS
19371938
BEGIN
19381939

19391940
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 6) WITH NOWAIT;
1941+
19401942

1943+
IF @UsualOwnerOfJobs IS NULL
1944+
SET @UsualOwnerOfJobs = SUSER_SNAME(0x01);
1945+
19411946
INSERT INTO #BlitzResults
19421947
( CheckID ,
19431948
Priority ,
@@ -1956,7 +1961,7 @@ AS
19561961
+ '] - meaning if their login is disabled or not available due to Active Directory problems, the job will stop working.' ) AS Details
19571962
FROM msdb.dbo.sysjobs j
19581963
WHERE j.enabled = 1
1959-
AND SUSER_SNAME(j.owner_sid) <> SUSER_SNAME(0x01);
1964+
AND SUSER_SNAME(j.owner_sid) <> @UsualOwnerOfJobs;
19601965
END;
19611966

19621967
/* --TOURSTOP06-- */

0 commit comments

Comments
 (0)