Condividi tramite


Metodo Job.RemoveSharedSchedule (Int32)

Removes the specified shared schedule from the job.

Spazio dei nomi  Microsoft.SqlServer.Management.Smo.Agent
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Sintassi

'Dichiarazione
Public Sub RemoveSharedSchedule ( _
    scheduleId As Integer _
)
'Utilizzo
Dim instance As Job 
Dim scheduleId As Integer

instance.RemoveSharedSchedule(scheduleId)
public void RemoveSharedSchedule(
    int scheduleId
)
public:
void RemoveSharedSchedule(
    int scheduleId
)
member RemoveSharedSchedule : 
        scheduleId:int -> unit
public function RemoveSharedSchedule(
    scheduleId : int
)

Parametri

  • scheduleId
    Tipo: System.Int32
    An Int32 value that specifies the ID value that uniquely identifies the shared schedule.

Esempi

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);

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)

Vedere anche

Riferimento

Job Classe

Overload RemoveSharedSchedule

Spazio dei nomi Microsoft.SqlServer.Management.Smo.Agent

Altre risorse

Pianificazione delle attività amministrative automatiche in SQL Server Agent

Automatizzazione delle attività amministrative (SQL Server Agent)

sp_delete_schedule (Transact-SQL)