Job.RemoveAllJobSchedules Job.RemoveAllJobSchedules Job.RemoveAllJobSchedules Method

Definition

Removes all shared and unshared schedules from the job.

Overloads

RemoveAllJobSchedules() RemoveAllJobSchedules() RemoveAllJobSchedules()

Removes all shared and unshared schedules from the job.

RemoveAllJobSchedules(Boolean) RemoveAllJobSchedules(Boolean) RemoveAllJobSchedules(Boolean)

Removes all unused schedules from the job.

RemoveAllJobSchedules() RemoveAllJobSchedules() RemoveAllJobSchedules()

Removes all shared and unshared schedules from the job.

public:
 void RemoveAllJobSchedules();
public void RemoveAllJobSchedules ();
Public Sub RemoveAllJobSchedules ()

Examples

The following code example deletes all schedules from the "Test Job" job.

C#

Server srv = new Server("(local)");  
Job jb = srv.JobServer.Jobs["Test Job"];  
jb.RemoveAllJobSchedules();  

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$jb = $srv.JobServer.Jobs["Test Job"]  
$jb.RemoveAllJobSchedules()  

Remarks

On successful execution, the JobSchedules collection property of the Job object is emptied. To reschedule the referenced job, create JobSchedule objects and add them to the JobSchedulescollection property of the Job object.

RemoveAllJobSchedules(Boolean) RemoveAllJobSchedules(Boolean) RemoveAllJobSchedules(Boolean)

Removes all unused schedules from the job.

public:
 void RemoveAllJobSchedules(bool keepUnusedSchedules);
public void RemoveAllJobSchedules (bool keepUnusedSchedules);
Public Sub RemoveAllJobSchedules (keepUnusedSchedules As Boolean)
Parameters
keepUnusedSchedules
Boolean Boolean Boolean

A Boolean value that specifies whether to keep the unused schedules from the removed job.

If True, the shared schedules are kept.

If False, the shared schedules are not kept.

Examples

The following code example deletes all non-shared schedules from the "Test Job" job.

C#

Server srv = new Server("(local)");  
Job jb = srv.JobServer.Jobs["Test Job"];  
jb.RemoveAllJobSchedules(true);  

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$jb = $srv.JobServer.Jobs["Test Job"]  
$jb.RemoveAllJobSchedules($TRUE)  

Remarks

On successful execution, the JobSchedules collection property of the Job object is emptied. To reschedule the referenced job, create JobSchedule objects and add them to the JobSchedulescollection property of the Job object.

Applies to