How do I script out jobs names in a server

  • I want to see all jobs with job owner in a server. How can i script it out with using t-sql command?

    Thank you in advance 🙂

  • selectname AS JobName

    , SUSER_SNAME(owner_sid) AS JobOwner

    from msdb.dbo.sysjobs

    or you could join msdb.dbo.sysjobs to master.sys.server_principals like so

    SELECTj.name AS JobName

    , sp.name AS JobOwner

    FROM msdb.dbo.sysjobs j INNER JOIN

    master.sys.server_principals sp ON j.owner_sid = sp.principal_id

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • It's working Thank you 🙂

  • Perry Whittle (7/15/2012)


    or you could join msdb.dbo.sysjobs to master.sys.server_principals like so

    SELECTj.name AS JobName

    , sp.name AS JobOwner

    FROM msdb.dbo.sysjobs j INNER JOIN

    master.sys.server_principals sp ON j.owner_sid = sp.principal_id

    Be careful. Jobs owned by logins that enter the instance via a Windows Group will not be returned by the above query.

    The first query supplied is the safer one to use:

    SELECT name AS JobName,

    SUSER_SNAME(owner_sid) AS JobOwner

    FROM msdb.dbo.sysjobs

    ORDER BY JobName;

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply