Export (0) Print
Expand All

Job.RemoveAllJobSteps Method

Removes all the job steps associated with the job.

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

public void RemoveAllJobSteps()

Successful execution of the RemoveAllJobSteps method disables the referenced job, and empties the JobSteps collection property of the Job object. To re-enable the referenced job, create JobStep objects and add them to the JobSteps collection property of the Job object.

The following code example disables the "Test Job" job and deletes all defined steps from it.

C#

Server srv = new Server("(local)");
Job jb = srv.JobServer.Jobs["Test Job"];
jb.RemoveAlljobSteps();

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = $srv.JobServer.Jobs["Test Job"]
$jb.RemoveAllJobSteps()

Community Additions

ADD
Show:
© 2014 Microsoft