Freigeben über


Job.RemoveSharedSchedule-Methode (Int32, Boolean)

Removes the specified shared schedule from the job and keeps unused schedules.

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

Syntax

'Declaration
Public Sub RemoveSharedSchedule ( _
    scheduleId As Integer, _
    keepUnusedSchedules As Boolean _
)
'Usage
Dim instance As Job 
Dim scheduleId As Integer 
Dim keepUnusedSchedules As Boolean

instance.RemoveSharedSchedule(scheduleId, _
    keepUnusedSchedules)
public void RemoveSharedSchedule(
    int scheduleId,
    bool keepUnusedSchedules
)
public:
void RemoveSharedSchedule(
    int scheduleId, 
    bool keepUnusedSchedules
)
member RemoveSharedSchedule : 
        scheduleId:int * 
        keepUnusedSchedules:bool -> unit
public function RemoveSharedSchedule(
    scheduleId : int, 
    keepUnusedSchedules : boolean
)

Parameter

  • scheduleId
    Typ: System.Int32
    An Int32 value that specifies the ID value that uniquely identifies the shared schedule.
  • keepUnusedSchedules
    Typ: System.Boolean
    A Boolean value that specifies whether to keep unused schedules. If True, unused schedules are kept. Otherwise, False.

Hinweise

This method was introduced in SQL Server 2008.

Beispiele

The following code example creates a job schedule, shares it between two jobs, then removes it from one of them.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
Job jb2 = new Job(srv.JobServer, "Second Test Job");
jb.Create();
jb2.Create();
JobSchedule jbsch = new JobSchedule(jb, "Test Job Schedule");
jbsch.Create();
jb2.AddSharedSchedule(jbsch.ID);
jb.RemoveSharedSchedule(jbsch.ID, true);

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job")
$jb2 = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Second Test Job")
$jb.Create()
$jb2.Create()
$jbsch = new-object Microsoft.SqlServer.Management.Smo.Agent.JobSchedule($jb, "Test Job Schedule")
$jbsch.Create()
$jb2.AddSharedSchedule($jbsch.ID)
$jb.RemoveSharedSchedule($jbsch.ID, $TRUE)

Siehe auch

Verweis

Job Klasse

RemoveSharedSchedule-Überladung

Microsoft.SqlServer.Management.Smo.Agent-Namespace

Andere Ressourcen

Planen von automatischen, administrativen Tasks im SQL Server-Agent

Automatisierte Administrationstasks (SQL Server-Agent)

sp_delete_schedule (Transact-SQL)