Skip to content

Instantly share code, notes, and snippets.

@DamianSuess
Created January 3, 2019 16:13
Show Gist options
  • Select an option

  • Save DamianSuess/390ba6f9e10a3218dfc13a0a8463c94f to your computer and use it in GitHub Desktop.

Select an option

Save DamianSuess/390ba6f9e10a3218dfc13a0a8463c94f to your computer and use it in GitHub Desktop.
TSQL Search Jobs for text

The following is an example of how to search SQL Jobs for text using TSQL

SQL 2005-2017

-- SQL 2005-2008 - Search all Jobs
SELECT j.job_id, s.srvname, j.name, js.step_id, js.command, j.enabled
FROM msdb.dbo.sysjobs j
JOIN msdb.dbo.sysjobsteps js ON js.job_id = j.job_id 
JOIN master.dbo.sysservers s ON s.srvid = j.originating_server_id
WHERE js.command LIKE N'%...%'

SQL 2000

-- SQL 2000 - Search all jobs containing text 
SELECT j.job_id, j.originating_server, j.name, js.step_id, js.command, j.enabled 
FROM msdb.dbo.sysjobs j
JOIN msdb.dbo.sysjobsteps js ON js.job_id = j.job_id
WHERE js.command LIKE N'%...%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment