To Find jobs related to a particular database.

  • All,

    If you have 10 databases mirrored and if you only failing over 5 of them....you only need to disable the jobs related to that databases that you are failing over.....so, how can you get that list of jobs using t-sql. Please advise.

    Thanks,

    SueTons.

    Regards,
    SQLisAwe5oMe.

  • Check out sysjobs and sysjobsteps in the msdb database.

  • JeremyE (2/5/2013)


    Check out sysjobs and sysjobsteps in the msdb database.

    Does anyone have any script for this?....Basically, I am looking for a script to get all the jobs with job names for a particular database and with execute command to disable those jobs....so, that I can copy the output and execute to disable them before I failover the database. Hope my requirement is clear.

    SueTons.

    Regards,
    SQLisAwe5oMe.

  • JeremyE was trying to teach you something new, Sue. Take a look at the two tables he recommended and you'll see how easy it is to do. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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