query to extract SQL from SQL jobs with T-SQL steps

warrenrapson
warrenrapson used Ask the Experts™
on
Hi all,

I'm looking for a query that I can use to query all my SQL Agent jobs that will expose/extract:
1. the jobs that have T-SQL steps, and
2. the SQL code of those jobs.

I need this to search all my jobs for references to a particular database.

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
SELECT *
FROM msdb.dbo.sysjobsteps
WHERE msdb.dbo.sysjobsteps.subsystem = 'TSQL'
  AND msdb.dbo.sysjobsteps.database_name = 'YOURDBNAMEHERE'

Author

Commented:
This is what I LOVE about Experts Exchange!!!

Author

Commented:
Perfect.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial