Поделиться через


Свойство Job.NextRunDate

Gets the date and time when the job is next scheduled to run.

Пространство имен:  Microsoft.SqlServer.Management.Smo.Agent
Сборка:  Microsoft.SqlServer.Smo (в Microsoft.SqlServer.Smo.dll)

Синтаксис

'Декларация
<SfcPropertyAttribute(SfcPropertyFlags.None Or SfcPropertyFlags.Expensive Or SfcPropertyFlags.Standalone)> _
Public ReadOnly Property NextRunDate As DateTime 
    Get
'Применение
Dim instance As Job 
Dim value As DateTime 

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

Значение свойства

Тип: System.DateTime
A DateTime value that specifies the date and time when the job is next scheduled to run.

Примеры

The following code example creates a job and an associated schedule, then displays 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.NextRunDate.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.NextRunDate

См. также

Справочник

Job Класс

Пространство имен Microsoft.SqlServer.Management.Smo.Agent

Другие ресурсы

Задачи автоматизированного администрирования (агент SQL Server)

sp_add_job (Transact-SQL)

Планирование автоматических административных задач в агенте SQL Server