July 26, 2013 at 1:13 pm
We have around 40+ jobs in the server box which hosts 5 DB instances
, of which i need to script some of the jobs to be run on a different server for testing.
I need all the jobs which use a particuler DB only .
Is there any Way i can filter and genrate scripts from SQLAgent,
If i give a 'wordsearch' like the DB name ,
Please advice....
July 29, 2013 at 11:24 am
any suggestions??
July 29, 2013 at 12:04 pm
You could query the MSDB to search for jobs with the DatabaseName you're interested in. At least that would give you the list of jobs you then would need to script manually through SSMS.
select distinct j.name from sysjobs j join sysjobsteps s on j.job_id = s.job_id
where s.command like '%DatabaseName%'
July 29, 2013 at 12:37 pm
there are dozens of scripts here on SSC for scripting out jobs:
http://www.sqlservercentral.com/search/?q=script+jobs&t=s
so from there you could then add a WHERE filter to any of those to limit to a specific database.
some jobs never explicitly mention a database name even thought hey fiddle with them...they might be querying sys.databases, or using dynamic sql to get database names, and run a loop / cursor thru the contents...so you need to take that into consideration as well.
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply