Who owns SQL Server Agent JOB ?


/** Verify / Determine / Identify the owner of SQL JOBS **/

USE

MSDB

GO

SELECT

j.[name] AS‘JobName’,

Enabled

=CASEWHEN j.Enabled= 0 THEN

‘No’

ELSE

‘Yes’

END

,

l

.[name] AS‘OwnerName’

FROM

MSDB.dbo.sysjobs j

INNER

JOINMaster.dbo.syslogins l

ON

j.owner_sid = l.

sid

ORDER

BY j.[name]

GO

 

—————————————————————————————————

 

/** To Change Ownership of SQL Server Agent JOB.

change @job_name and @owner_login_name **/

EXEC

SP_UPDATE_JOB@job_name =‘DB Weekly MaintenancePlan.Subplan_1’, @owner_login_name =

‘sqldbaadmin’

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: