Export (0) Print
Expand All

Job.RemoveAllJobSchedules Method (Boolean)

Removes all unused schedules from the job.

Namespace:  Microsoft.SqlServer.Management.Smo.Agent
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public void RemoveAllJobSchedules(
	bool keepUnusedSchedules
)

Parameters

keepUnusedSchedules
Type: System.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.

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.

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)

Community Additions

ADD
Show:
© 2014 Microsoft