共用方式為


Job.DeleteLevel 屬性

Gets or sets the completion action that determines whether to delete the job definition when the job finishes execution.

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

語法

'宣告
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public Property DeleteLevel As CompletionAction 
    Get 
    Set
'用途
Dim instance As Job 
Dim value As CompletionAction 

value = instance.DeleteLevel

instance.DeleteLevel = value
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public CompletionAction DeleteLevel { get; set; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property CompletionAction DeleteLevel {
    CompletionAction get ();
    void set (CompletionAction value);
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member DeleteLevel : CompletionAction with get, set
function get DeleteLevel () : CompletionAction 
function set DeleteLevel (value : CompletionAction)

屬性值

型別:Microsoft.SqlServer.Management.Smo.Agent.CompletionAction
A CompletionAction object value that specifies whether to delete the job definition.

備註

If directed, Microsoft SQL Server Agent can delete a job definition when execution succeeds or fails. Jobs can also be deleted regardless of success or failure of the job. By default, jobs are not deleted when execution finishes.

範例

The following code example creates a new job and displays the date on which it was last modified.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
jb.DeleteLevel = CompletionAction.Always;

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job")
$jb.DeleteLevel = [Micrososft.SqlServer.Management.Smo.Agent.CompletionAction]::Always

請參閱

參考

Job 類別

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

其他資源

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

sp_add_job (Transact-SQL)

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