Freigeben über


Job-Klasse

The Job class represents a Microsoft SQL Server Agent job.

Vererbungshierarchie

System.Object
  Microsoft.SqlServer.Management.Smo.SmoObjectBase
    Microsoft.SqlServer.Management.Smo.SqlSmoObject
      Microsoft.SqlServer.Management.Smo.NamedSmoObject
        Microsoft.SqlServer.Management.Smo.Agent.AgentObjectBase
          Microsoft.SqlServer.Management.Smo.Agent.Job

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

Syntax

'Declaration
Public NotInheritable Class Job _
    Inherits AgentObjectBase _
    Implements IAlterable, ICreatable, IDroppable, IRenamable,  _
    IScriptable
'Usage
Dim instance As Job
public sealed class Job : AgentObjectBase, IAlterable, 
    ICreatable, IDroppable, IRenamable, IScriptable
public ref class Job sealed : public AgentObjectBase, 
    IAlterable, ICreatable, IDroppable, IRenamable, IScriptable
[<SealedAttribute>]
type Job =  
    class 
        inherit AgentObjectBase 
        interface IAlterable 
        interface ICreatable 
        interface IDroppable 
        interface IRenamable 
        interface IScriptable 
    end
public final class Job extends AgentObjectBase implements IAlterable, ICreatable, IDroppable, IRenamable, IScriptable

Der Job-Typ macht folgende Elemente verfügbar.

Konstruktoren

  Name Beschreibung
Öffentliche Methode Job() Initializes a new instance of the Job class.
Öffentliche Methode Job(JobServer, String) Initializes a new instance of the Job class on the specified instance of Microsoft SQL Server Agent and with the specified name.
Öffentliche Methode Job(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

Zum Anfang

Eigenschaften

  Name Beschreibung
Öffentliche Eigenschaft Category Gets or sets the category to which the job belongs.
Öffentliche Eigenschaft CategoryID Gets the ID value that uniquely identifies the job category.
Öffentliche Eigenschaft CategoryType Gets or sets the type of category, with respect to local or multiserver jobs.
Öffentliche Eigenschaft CurrentRunRetryAttempt Gets the number of times Microsoft SQL Server Agent has attempted to run the job unsuccessfully.
Öffentliche Eigenschaft CurrentRunStatus Gets the current execution status of the job.
Öffentliche Eigenschaft CurrentRunStep Gets information about the job step that is currently running.
Öffentliche Eigenschaft DateCreated Gets the date and time when the job was created.
Öffentliche Eigenschaft DateLastModified Gets the date and time when the job was last modified.
Öffentliche Eigenschaft DeleteLevel Gets or sets the completion action that determines whether to delete the job definition when the job finishes execution.
Öffentliche Eigenschaft Description Gets or sets the textual description of the job.
Öffentliche Eigenschaft EmailLevel Gets or sets the completion action that determines whether to send an e-mail notification to an operator when the job finishes execution.
Öffentliche Eigenschaft EventLogLevel Gets or sets the completion action that determines whether to generate an operating system event log entry when the job finishes execution.
Öffentliche Eigenschaft HasSchedule Gets the Boolean property value that specifies whether the job has at least one schedule.
Öffentliche Eigenschaft HasServer Gets the Boolean property value that specifies whether the job has a target server assigned for multiple-server operations.
Öffentliche Eigenschaft HasStep Gets the Boolean property value that specifies whether the job has at least one job step.
Öffentliche Eigenschaft IsEnabled Gets or sets the Boolean property value that specifies whether the job is enabled.
Öffentliche Eigenschaft JobID Gets the job ID value.
Öffentliche Eigenschaft JobSchedules Gets a collection of JobSchedule objects that represent the schedules assigned to the job.
Öffentliche Eigenschaft JobSteps Gets a collection of JobStep objects that represent the job steps defined for the job.
Öffentliche Eigenschaft JobType Gets the job type, which specifies whether the job is local or multiserver.
Öffentliche Eigenschaft LastRunDate Gets the date and time when the job was last run.
Öffentliche Eigenschaft LastRunOutcome Gets the result of the job from the last time it completed execution.
Öffentliche Eigenschaft Name Gets or sets the name of the Job. (Überschreibt NamedSmoObject.Name.)
Öffentliche Eigenschaft NetSendLevel Gets or sets the completion action that determines whether to net-send a notification to an operator when the job finishes execution.
Öffentliche Eigenschaft NextRunDate Gets the date and time when the job is next scheduled to run.
Öffentliche Eigenschaft NextRunScheduleID Gets the ID value of the schedule that is responsible for the next execution of the job.
Öffentliche Eigenschaft OperatorToEmail Gets or sets the operator that receives notification by e-mail when the job finishes execution.
Öffentliche Eigenschaft OperatorToNetSend Gets or sets the operator that receives a net-send notification when the job finishes execution.
Öffentliche Eigenschaft OperatorToPage Gets or sets the operator that receives a pager notification when the job finishes execution.
Öffentliche Eigenschaft OriginatingServer Gets the name of the server that is acting as the master server in a multiserver job.
Öffentliche Eigenschaft OwnerLoginName Gets or sets the owner of the job.
Öffentliche Eigenschaft PageLevel Gets or sets the completion action that determines whether to send a pager notification to an operator when the job finishes execution.
Öffentliche Eigenschaft Parent Gets or sets the JobServer object that is the parent of the Job object.
Öffentliche Eigenschaft Properties Gets a collection of Property objects that represent the object properties. (Geerbt von SqlSmoObject.)
Öffentliche Eigenschaft StartStepID Gets or sets the ID value of the first job step in the sequence to be executed.
Öffentliche Eigenschaft State Gets the state of the referenced object. (Geerbt von SmoObjectBase.)
Öffentliche Eigenschaft Urn Gets the Uniform Resource Name (URN) address value that uniquely identifies the object. (Geerbt von SqlSmoObject.)
Öffentliche Eigenschaft UserData Gets or sets user-defined data associated with the referenced object. (Geerbt von SmoObjectBase.)
Öffentliche Eigenschaft VersionNumber Gets a system-maintained value that is incremented every time the job is modified.

Zum Anfang

Methoden

  Name Beschreibung
Öffentliche Methode AddSharedSchedule Adds a shared schedule to the Microsoft SQL Server Agent job.
Öffentliche Methode Alter Updates any Job object property changes on an instance of Microsoft SQL Server. 
Öffentliche Methode ApplyToTargetServer Adds a server to the list of target servers maintained for the referenced Microsoft SQL Server Agent job.
Öffentliche Methode ApplyToTargetServerGroup Adds one or more servers to the list of target servers maintained for the referenced Microsoft SQL Server Agent job.
Öffentliche Methode Create Creates a job on the instance of Microsoft SQL Server as defined by the Job object.
Öffentliche Methode DeleteJobStepLogs(DateTime) Deletes job step log files that are older than the specified date.
Öffentliche Methode DeleteJobStepLogs(Int32) Deletes job step log files that are larger that the specified log ID number.
Öffentliche Methode Discover Discovers a list of type Object. (Geerbt von SqlSmoObject.)
Öffentliche Methode Drop() Removes an existing job.
Öffentliche Methode Drop(Boolean) Removes an existing job.
Öffentliche Methode EnumAlerts Enumerates a list of Agent alerts that cause automated execution of the referenced job.
Öffentliche Methode EnumHistory() Enumerates a list of execution history associated with the referenced job.
Öffentliche Methode EnumHistory(JobHistoryFilter) Enumerates a list of execution history associated with the referenced job.
Öffentliche Methode EnumJobStepLogs() Enumerates a list of job step log files for the referenced job.
Öffentliche Methode EnumJobStepLogs(Int32) Enumerates a list of job step log files for the job step with the specified ID value.
Öffentliche Methode EnumJobStepLogs(String) Enumerates a list of job step log files for the job step with the specified name.
Öffentliche Methode EnumJobStepsByID Returns an array of JobStep objects that belong to the referenced job and that are ordered by ID value.
Öffentliche Methode EnumTargetServers Enumerates a list of execution target servers that have been assigned to the referenced job.
Öffentliche Methode Equals (Geerbt von Object.)
Geschützte Methode FormatSqlVariant Formats an object as SqlVariant type. (Geerbt von SqlSmoObject.)
Geschützte Methode GetContextDB Gets the context database that is associated with this object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetDBName Gets the database name that is associated with the object. (Geerbt von AgentObjectBase.)
Öffentliche Methode GetHashCode (Geerbt von Object.)
Geschützte Methode GetPropValue Gets a property value of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetPropValueOptional Gets a property value of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetPropValueOptionalAllowNull Gets a property value of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Geschützte Methode GetServerObject Gets the server of the SqlSmoObject object. (Geerbt von SqlSmoObject.)
Öffentliche Methode GetType (Geerbt von Object.)
Öffentliche Methode Initialize() Initializes the object and forces the properties be loaded. (Geerbt von SqlSmoObject.)
Öffentliche Methode Initialize(Boolean) Initializes the object and forces the properties be loaded. (Geerbt von SqlSmoObject.)
Öffentliche Methode Invoke Runs the job.
Geschützte Methode IsObjectInitialized Verifies whether the object has been initialized. (Geerbt von SqlSmoObject.)
Geschützte Methode IsObjectInSpace Verifies whether the object is isolated or connected to the instance of SQL Server. (Geerbt von SqlSmoObject.)
Öffentliche Methode PurgeHistory Removes system records maintaining execution history for the referenced job.
Öffentliche Methode Refresh Refreshes the object and retrieves properties when the object is next accessed. (Geerbt von SqlSmoObject.)
Öffentliche Methode RemoveAllJobSchedules() Removes all shared and unshared schedules from the job.
Öffentliche Methode RemoveAllJobSchedules(Boolean) Removes all unused schedules from the job.
Öffentliche Methode RemoveAllJobSteps Removes all the job steps associated with the job.
Öffentliche Methode RemoveFromTargetServer Removes an execution target server from the list of target servers maintained for a job.
Öffentliche Methode RemoveFromTargetServerGroup Removes a group of execution target servers from the list of target servers maintained for a job.
Öffentliche Methode RemoveSharedSchedule(Int32) Removes the specified shared schedule from the job.
Öffentliche Methode RemoveSharedSchedule(Int32, Boolean) Removes the specified shared schedule from the job and keeps unused schedules.
Öffentliche Methode Rename Renames the job.
Öffentliche Methode Script() Generates a Transact-SQL script that can be used to re-create the Microsoft SQL Server Agent job.
Öffentliche Methode Script(ScriptingOptions) Generates a Transact-SQL script that can be used to re-create the Microsoft SQL Server Agent job as specified by the scripting options.
Geschützte Methode SetParentImpl Sets the parent of the SqlSmoObject to the newParent parameter. (Geerbt von SqlSmoObject.)
Öffentliche Methode Start() Runs the referenced job.
Öffentliche Methode Start(String) Runs the referenced job starting at the specified job step.
Öffentliche Methode Stop Stops executing the referenced job.
Öffentliche Methode ToString Returns a String that represents the referenced object. (Geerbt von SqlSmoObject.)
Öffentliche Methode Validate Validates the state of an object. (Geerbt von SmoObjectBase.)

Zum Anfang

Ereignisse

  Name Beschreibung
Öffentliches Ereignis PropertyChanged Represents the event that occurs when a property is changed. (Geerbt von SqlSmoObject.)
Öffentliches Ereignis PropertyMetadataChanged Represents the event that occurs when property metadata changes. (Geerbt von SqlSmoObject.)

Zum Anfang

Explizite Schnittstellenimplementierungen

  Name Beschreibung
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.Discover Discovers any dependencies. Verweisen Sie nicht direkt im Code auf dieses Element. Unterstützt die SQL Server-Infrastruktur. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetDomainRoot Returns the root of the domain. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetParent Gets the parent of this object. Verweisen Sie nicht direkt im Code auf dieses Element. Unterstützt die SQL Server-Infrastruktur. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetPropertyType Gets the type of the specified property. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetPropertyValue Gets the value of the specified property. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Verweisen Sie nicht direkt im Code auf dieses Element. Unterstützt die SQL Server-Infrastruktur. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode IAlienObject.SetPropertyValue Sets the property value. (Geerbt von SqlSmoObject.)
Explizite SchnittstellenimplementierungPrivate Methode ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (Geerbt von SqlSmoObject.)

Zum Anfang

Hinweise

To get or set Job object properties, users must be a member of the SQLAgentUserRole database role on the MSDB database, or be the owner of the job, or be a member of the sysadmin fixed server role.

To create a job, users must be a member of the SQLAgentUserRole, SQLAgentReaderRole, and SQLAgentOperatorRole database roles on the MSDB database, or be a member of the sysadmin fixed server role.

To drop a job, users must be a member of the SQLAgentUserRole database role on the MSDB database, or be the owner of the job, or be a member of the sysadmin fixed server role.

Thread Safety

Alle öffentlichen, statischen Elemente dieses Typs (Shared in Microsoft Visual Basic) sind für Vorgänge mit mehreren Threads sicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Beispiele

Planen von automatischen, administrativen Tasks im SQL Server-Agent

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic)-Elemente dieses Typs sind Threadsicher. Für Instanzelemente wird die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

Microsoft.SqlServer.Management.Smo.Agent-Namespace

Andere Ressourcen

Automatisierte Administrationstasks (SQL Server-Agent)

sp_add_job (Transact-SQL)