SQL SERVER DBA, Linux and Azure: SQL Server script to get a list of all jobs that access a database in SQL server?

SQL Server script to get a list of all jobs that access a database in SQL server?

 This will work for Agent jobs that have T-SQL job steps pointing to a database.


USE msdb

SELECT DISTINCT j.name AS JobName

FROM sysjobs j

INNER JOIN sysjobsteps js ON j.job_id=js.job_id

WHERE js.database_name='sqldbanow'


This, however, will not catch things where databases are accessed from fully qualified name references in code. Nor will it catch other things like SSIS job steps where the package references your database.

No comments:

Post a Comment