Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2008
    Posts
    2

    Unanswered: How do I determin who owns a job?

    I need a script or stored procedure to tell me who owns what jobs. I have something like 150 and one of my job creators is no longer with our department. His account (NT domain) is still active but he is no longer working with these jobs and they need to be owned by someone else. Is there an easy way to do this?

    Dale

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    in sql 2000....

    msdb.dbo.sysjobs.owner_sid
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    That works in 2005 as well, I believe. i had to do very little updating to my scripts for jobs on SQL 2005.

    Code:
    select suser_sname(owner_sid), name
    from msdb.dbo.sysjobs.owner_sid

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Why wouldn't all your jobs be owned by dbo?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Mar 2008
    Posts
    2
    Unfortunately not. As control of the SQL server has loosened over the years developers - other than DBAs - have built jobs and are not managing them. So along come more code builders to modify what we have.

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Ah, the wild west production model
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by Brett Kaiser
    Why wouldn't all your jobs be owned by dbo?
    Jobs exist in msdb, but they can affect any database on the SQL instance (or beyond). In nearly every case I can think of, jobs ought to be owned by a Windows Login (in fact, jobs are very difficult for dbo to own).

    I'd recommend using sp_check_for_owned_jobs to see which jobs they old owner still owns (although a query might be easier to use), then use sp_update_job to set the new owner.

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •