Job.HasSchedule Property

 

Gets the Boolean property value that specifies whether the job has at least one schedule.

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

[SfcPropertyAttribute(SfcPropertyFlags.None | SfcPropertyFlags.Expensive | SfcPropertyFlags.Standalone)]
public bool HasSchedule { get; }

Property Value

Type: System.Boolean

A Boolean value that specifies whether the job has a schedule assigned or not.

If True, the job has at least one schedule.

If False (default), the job has no schedule.

You can query the JobSchedules collection property to evaluate which schedule is enabled for the job. If the HasSchedule property is False, the JobSchedules collection property is empty.

The following code example specifies that the job has at least one schedule.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
jb.HasSchedule = true;

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job")
$jb.HasSchedule = $TRUE
Return to top
Show: