Agent Jobs

Find All SQL Job Owners

Here’s some quick SQL logic to return all the Job Owners.

use master;
set nocount on

if object_id('tempdb..#job_owners') is not null
drop table	#job_owners
create table	#job_owners
(
server_name varchar(255)
,	job_owner_name	varchar(255)
,	job_name varchar(255)
,	date_created	datetime
)
insert into	#job_owners
select
'server_name' = @@servername
,	'job_owner_name'	= upper(suser_sname(owner_sid))
,	'job_name' = upper(sj.name)
,	'date_created' = date_created
from
msdb..sysjobs sj

select
server_name
,	job_owner_name
,	job_name
,	'date_created' = left(date_created, 12) + ' ' + datename(dw, date_created) from
#job_owners
order by
date_created
,	job_name asc

drop table #job_owners
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