Job.Parent Property

Gets or sets the JobServer object that is the parent of the Job object.

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

[SfcObjectAttribute(SfcObjectRelationship.ParentObject)]
public JobServer Parent { get; set; }

Property Value

Type: Microsoft.SqlServer.Management.Smo.Agent.JobServer
A JobServer object value that specifies the parent of the Job object.

The JobServer object represents the Microsoft SQL Server Agent running on the instance of SQL Server.

The following code example sets the name and parent of a job, then creates it.

C#

Server srv = new Server("(local)");
Job jb = new Job();
jb.Name = "Test Job";
jb.Parent = srv.JobServer;
jb.Create();

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job
$jb.Name = "Test Job"
$jb.Parent = $srv.JobServer
$jb.Create()

Community Additions

ADD
Show: