Showing posts with label job. Show all posts
Showing posts with label job. Show all posts

Friday, March 30, 2012

Query/Report for Owner of all SQL Jobs

Is there a query/report that I can run against all our SQL servers to see who the 'owner' of each job is?
If so, can this be run in SQL Server Enterprise Manager 8, SQL Server Management Studio or Hyena?Usual caveats re querying system tables (run at own risk etc):
SELECT J.name AS JobName
, L.name AS JobOwner
FROM msdb.dbo.sysjobs_view J
INNER JOIN
master.dbo.syslogins L
ON J.owner_sid = L.sid
HTH|||Thank you very much! I'm just a newbie DBA admin :)

Monday, March 12, 2012

Query to find who runs jobs

I would like to create a query to find what user owns the job. It probably is in the master db, but I wouldn't know where to begin other than that. Telling me how to either change the job owner or create a job through t-sql would also help. Thanks
-Kyle

Not quite. You should check msdb for all things SQL Agent/job related.

Rather than querying the tables directly though, i'd recommend using the system sprocs:

Check out sp_update_job, sp_add_job, sp_help_job (plus associated sprocs) in Books Online.

HTH!