Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Job.JobSteps Property

 

Applies To: SQL Server 2016 Preview

Gets a collection of JobStep objects that represent the job steps defined for the job.

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

[SfcObjectAttribute(SfcContainerRelationship.ChildContainer, 
	SfcContainerCardinality.ZeroToAny, typeof(JobStep))]
public JobStepCollection JobSteps { get; }

Property Value

Type: Microsoft.SqlServer.Management.Smo.Agent.JobStepCollection

A JobStepCollection object value that specifies a collection of JobStep objects.

Legacy Code Example

The following code example creates a job and an associated job step.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
jb.Create();
JobStep jbstp = new JobStep(jb, "Test Job Step");
jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
jbstp.Create();
Console.WriteLine(jb.JobSteps.ToString());

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job23", 3)
$jb.Create()
$jbstp = new-object Microsoft.SqlServer.Management.Smo.Agent.JobStep($jb, "Test Job Step")
$jbstp.OnSuccessAction = [Microsoft.SqlServer.Management.Smo.Agent.StepCompletionAction]::QuitWithSuccess
$jbstp.OnFailAction = [Microsoft.SqlServer.Management.Smo.Agent.StepCompletionAction]::QuitWithFailure
$jbstp.Create()
Write-Host $jb.JobSteps
Return to top
Show:
© 2015 Microsoft