SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How can I disable a Job via TSQL


How can I disable a Job via TSQL

Author
Message
Scott-144766
Scott-144766
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1927 Visits: 1109
Can you do this on a remote server? We have a mirrored database and I want to write a script to enable and disable jobs on both servers in the event of a failover (the script to be run manually).

--
Scott
altafhahmed
altafhahmed
SSC-Enthusiastic
SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)

Group: General Forum Members
Points: 148 Visits: 168
thanks very helpful
mohankollu 63101
mohankollu 63101
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 354
SELECT job_id,[name] FROM msdb.dbo.sysjobs


EXEC msdb.dbo.SP_UPDATE_JOB @job_id = 'B9D5575F-56FB-4B34-8180-2728FB70BC0F' , @enabled =1
Otis P. Driftwood
Otis P. Driftwood
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 Visits: 43
Does this wait if the job is running at the time before executing the next statement if used in a SP? I've got a job running every five minutes checking for a change to a bunch of tables being fed via web services on another server and refreshes a local copy. I'd like to disable the job, refresh the local copy, which sometimes takes just around or more than five minutes, then re-enable the job running every five minutes.

The timing is a bit too erratic to be tested and I wonder if anyone knows for sure. It would save me considerable time finding out if someone already knew.

Thanks.
Joe
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search