Created
April 14, 2023 14:17
-
-
Save fassetar/b5e330543eb3b909c8979702465c91b5 to your computer and use it in GitHub Desktop.
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 characters
-- SQL CLEAN UP -- | |
/* Find jobs still owned by ppl */ | |
SELECT name,* | |
FROM msdb..sysjobs | |
WHERE owner_sid = SUSER_SID('{USERNAME}') | |
exec msdb..sp_update_job | |
@job_name = '{JOBNAME}', | |
@owner_login_name = 'sa'; | |
-- find database still owned | |
SELECT name, suser_sname(owner_sid) AS Database_Owner FROM sys.databases | |
--Change DBNAME with your database name-- | |
USE {DATABASENAME} | |
GO | |
sp_changedbowner 'sa' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment