| Author |
Topic |
|
WoodHouse
Posting Yak Master
211 Posts |
Posted - 2009-12-17 : 05:05:59
|
| HiAny way to disable all the job in SQL 2005 in a single queryThanks |
|
|
saralstalin
Starting Member
11 Posts |
Posted - 2009-12-17 : 07:42:28
|
| Run the below query UPDATE msdb.dbo.sysjobs SET enabled = 0 Saral S Stalin |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-23 : 01:24:38
|
Another method isdeclare @sql varchar(max)set @sql=''select @sql=@sql+' EXEC msdb..sp_update_job @job_id='''+cast(job_id as varchar(100))+''',@enabled=0;' from msdb..sysjobs where enabled=1exec(@sql) MadhivananFailing to plan is Planning to fail |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2009-12-23 : 08:57:06
|
Test is a test.declare @sql varchar(max)set @sql=''select @sql=@sql+' EXEC msdb..sp_update_job @job_id='''+cast(job_id as varchar(100))+''',@enabled=0;' from msdb..sysjobs where enabled=1exec(@sql) =================================================Creating tomorrow's legacy systems today. One crisis at a time. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-23 : 09:02:36
|
| Graz.Strange. Now I copy your code and try to post but it hangsMadhivananFailing to plan is Planning to fail |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2009-12-23 : 09:52:48
|
| Got it. When I post as a non-administrator I get the same error you do. I'll look into it over the holidays.=================================================Creating tomorrow's legacy systems today. One crisis at a time. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-23 : 10:16:20
|
quote: Originally posted by graz Got it. When I post as a non-administrator I get the same error you do. I'll look into it over the holidays.=================================================Creating tomorrow's legacy systems today. One crisis at a time.
Thanks MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-08 : 03:02:24
|
I will try too (copy from graz):declare @sql varchar(max)set @sql=''select @sql=@sql+' EXEC msdb..sp_update_job @job_id='''+cast(job_id as varchar(100))+''',@enabled=0;' from msdb..sysjobs where enabled=1exec(@sql) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-08 : 03:51:12
|
| It didn't work for me as I specified earlierThat was why I formatted differently and posted (see my first reply)MadhivananFailing to plan is Planning to fail |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-01-08 : 09:53:55
|
| I disable SQL Agent when I need to disable all jobs |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-08 : 09:59:00
|
quote: Originally posted by saralstalin Run the below query UPDATE msdb.dbo.sysjobs SET enabled = 0 Saral S Stalin
This works not reliable, better use sp_updatejob like madhi wrote.We have had a problem with a solution like yours in the past. The agent has shown the empty box which means job is not enabled but the job startet anyway... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|