Classe Job

The Job class represents a Microsoft SQL Server Agent job.

Hiérarchie d'héritage

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

Espace de noms :  Microsoft.SqlServer.Management.Smo.Agent
Assembly :  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Syntaxe

'Déclaration
Public NotInheritable Class Job _
    Inherits AgentObjectBase _
    Implements IAlterable, ICreatable, IDroppable, IRenamable,  _
    IScriptable
'Utilisation
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

Le type Job expose les membres suivants.

Constructeurs

  Nom Description
Méthode publique Job() Initializes a new instance of the Job class.
Méthode publique 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.
Méthode publique 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

Haut de la page

Propriétés

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

Haut de la page

Méthodes

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

Haut de la page

Événements

  Nom Description
Événement public PropertyChanged Represents the event that occurs when a property is changed. (hérité de SqlSmoObject.)
Événement public PropertyMetadataChanged Represents the event that occurs when property metadata changes. (hérité de SqlSmoObject.)

Haut de la page

Implémentations d'interfaces explicites

  Nom Description
Implémentation d'interface expliciteMéthode privée IAlienObject.Discover Discovers any dependencies. Ne faites pas directement référence à ce membre dans votre code. Il prend en charge l'infrastructure SQL Server. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetDomainRoot Returns the root of the domain. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetParent Gets the parent of this object. Ne faites pas directement référence à ce membre dans votre code. Il prend en charge l'infrastructure SQL Server. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetPropertyType Gets the type of the specified property. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetPropertyValue Gets the value of the specified property. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Ne faites pas directement référence à ce membre dans votre code. Il prend en charge l'infrastructure SQL Server. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée IAlienObject.SetPropertyValue Sets the property value. (hérité de SqlSmoObject.)
Implémentation d'interface expliciteMéthode privée ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (hérité de SqlSmoObject.)

Haut de la page

Notes

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

Tout membre statique public (Partagé dans Microsoft Visual Basic) de ce type est sûr dans le cadre des opérations à plusieurs threads. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Exemples

Planification des tâches administratives automatiques dans l'Agent SQL Server

Sécurité des threads

Tous les membres publics static (Shared dans Visual Basic) de ce type sont thread-safe. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Voir aussi

Référence

Espace de noms Microsoft.SqlServer.Management.Smo.Agent

Autres ressources

Tâches d'administration automatisée (Agent SQL Server)

sp_add_job (Transact-SQL)