Created
May 13, 2022 16:17
-
-
Save Otterpohl/a75ffbf2e33aa8f75d1364e4e3a8dd77 to your computer and use it in GitHub Desktop.
Revisions
-
Otterpohl created this gist
May 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ SELECT 'EXEC msdb.dbo.sp_update_job @job_id=N''' + CAST(j.job_id AS VARCHAR(150)) + ''', @owner_login_name=N''sa'' ' FROM msdb.dbo.sysjobs AS j INNER JOIN master.sys.syslogins AS L ON j.owner_sid = L.sid INNER JOIN msdb.dbo.syscategories AS C ON C.category_id = j.category_id WHERE msdb.dbo.SQLAGENT_SUSER_SNAME(j.owner_sid) <> 'sa';