Job Constructor (JobServer, String, Int32)

Initializes a new instance of the Job class on the specified instance of SQL Server Agent and with the specified name and category

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

public Job(
	JobServer jobServer,
	string name,
	int categoryID
)

Parameters

jobServer
Type: Microsoft.SqlServer.Management.Smo.Agent.JobServer
A JobServer object value that specifies the instance of SQL Server Agent that is running on the instance of SQL Server.
name
Type: System.String
A String value that specifies the name of the job.
categoryID
Type: System.Int32
A In32 value that specifies the job category ID number.

The following code example creates a new instance of the Job class running on the default local server with the name "Test Job" and a job category ID of 1.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job", 1);

PowerShell

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

Community Additions

ADD
Show: