Export (0) Print
Expand All

Job.JobID Property

Gets the job ID value.

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

[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.Matrix)]
public Guid JobID { get; }

Property Value

Type: Guid
A Guid system object value that specifies the job ID value.

Each Microsoft SQL Server Agent job is identified by a system-generated GUID. The identifier is a 32-character string representing a hexadecimal number.

The following code example creates a job and displays its GUID ID value.

C#

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
jb.Create();
Console.WriteLine(jb.JobID.ToString());

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$jb = new-object Microsoft.SqlServer.Management.Smo.Agent.Job($srv.JobServer, "Test Job")
$jb.Create()
Write-Host $jb.JobID.ToString()

Community Additions

ADD
Show:
© 2014 Microsoft