Which databaes a job is attached to

  • Hello - I'm using SQL Server 2008 Standard.

    What is the T-SQL to use to find out which databaes a job is attached to?

    If I click "Edit" in the "Job step list", I can see the Database in teh drop down. Where is that stored? I don't see it in sysjobs.

    I'd like to be able to see if any jobs are attached to a database before taking it offline.

    Thanks

    Dave

  • That info is in sysjobsteps

  • Thank you - your reply enabled me to put a query together for active jobs

    -- How to find the name and database of enabled jobs

    select [name], database_name

    from sysjobs sj

    join sysjobsteps so

    on sj.job_id=so.job_id

    where [enabled]=1

  • Your welcome Dave!

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

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