共用方式為


Job.EnumHistory 方法 (JobHistoryFilter)

Enumerates a list of execution history associated with the referenced job.

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

語法

'宣告
Public Function EnumHistory ( _
    filter As JobHistoryFilter _
) As DataTable
'用途
Dim instance As Job 
Dim filter As JobHistoryFilter 
Dim returnValue As DataTable 

returnValue = instance.EnumHistory(filter)
public DataTable EnumHistory(
    JobHistoryFilter filter
)
public:
DataTable^ EnumHistory(
    JobHistoryFilter^ filter
)
member EnumHistory : 
        filter:JobHistoryFilter -> DataTable
public function EnumHistory(
    filter : JobHistoryFilter
) : DataTable

參數

傳回值

型別:System.Data.DataTable
A DataTable object value that contains execution history data for the referenced job.

範例

The following code example creates a job then displays its filtered execution history.

C#

Server srv = new Server("(local)");
Job jb = srv.JobServer.Jobs["Test Job"];
JobHistoryFilter jhf = new JobHistoryFilter();
jhf.JobID = jb.JobID
DataTable jobHistory = jb.EnumHistory(jhf);

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = $srv.JobServer.Jobs["Test Job"]
$jhf = new-object Microsoft.SqlServer.Management.Smo.Agent.JobHistoryFilter
$jhf.JobID = $jb.JobID
$jobHistory = $jb.EnumHistory($jhf)

請參閱

參考

Job 類別

EnumHistory 多載

Microsoft.SqlServer.Management.Smo.Agent 命名空間

其他資源

使用 SQL Server Agent 排程自動管理工作

自動化管理工作 (SQL Server Agent)

sp_help_job (Transact-SQL)