共用方式為


NextRunScheduleID 屬性

Gets the ID value of the schedule that is responsible for the next execution of the job.

命名空間:  Microsoft.SqlServer.Management.Smo.Agent
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
<SfcPropertyAttribute(SfcPropertyFlags.None Or SfcPropertyFlags.Expensive Or SfcPropertyFlags.Standalone)> _
Public ReadOnly Property NextRunScheduleID As Integer
    Get
'用途
Dim instance As Job
Dim value As Integer

value = instance.NextRunScheduleID
[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Expensive|SfcPropertyFlags.Standalone)]
public int NextRunScheduleID { get; }
[SfcPropertyAttribute(SfcPropertyFlags::None|SfcPropertyFlags::Expensive|SfcPropertyFlags::Standalone)]
public:
property int NextRunScheduleID {
    int get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Expensive|SfcPropertyFlags.Standalone)>]
member NextRunScheduleID : int
function get NextRunScheduleID () : int

屬性值

型別:System. . :: . .Int32
An Int32 value that specifies the ID value of the schedule that next runs the job.

備註

The ID value is generated by Microsoft SQL Server and is stored in the system tables.

範例

The following code example creates a job and an associated schedule, then displays the ID of the next scheduled run date.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
jb.Create();
JobSchedule jbsch = new JobSchedule(jb, "Test Job Schedule");
jbsch.FrequencyTypes = FrequencyTypes.Daily;
jbsch.FrequencySubDayTypes = FrequencySubDayTypes.Minute;
jbsch.FrequencySubDayinterval = 30;
Timespan ts1 = new Timespan(9, 0, 0);
Timespan ts2 = new Timespan(17, 0, 0);
jbsch.ActiveStartTimeOfDay = ts1;
jbsch.ActiveEndTimeOfDay = ts2;
jbsch.FequencyInterval = 1;
DateTime d = new DateTime(2004, 1, 1);
jbsch.ActiveStartDate = d;
jbsch.Create();
Console.WriteLine(jb.NextRunScheduleID.ToString());

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job")
$jb.Create()
$jbsch = new-object Microsoft.SqlServer.Management.Smo.Agent.JobSchedule($jb, "Test Job Schedule")
$jbsch.FrequencyTypes = [Microsoft.SqlServer.Management.Smo.Agent.FrequencyTypes]::Daily
$jbsch.FrequencySubDayTypes = [Microsoft.SqlServer.Management.Smo.Agent.FrequencySubDayTypes]::Minute
$jbsch.FrequencySubDayinterval = 30
$ts1 = new-object System.TimeSpan(9, 0, 0)
$ts2 = new-object System.TimeSpan(17, 0, 0)
$jbsch.ActiveStartTimeOfDay = $ts1
$jbsch.ActiveEndTimeOfDay = $ts2
$jbsch.FrequencyInterval = 1
$d = new-object System.DateTime(2003, 1, 1)
$jbsch.ActiveStartDate = $d
$jbsch.Create()
Write-Host $jb.NextRunScheduleID