Compartir a través de


Clase Job

The Job class represents a Microsoft SQL Server Agent job.

Jerarquía de herencia

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

Espacio de nombres:  Microsoft.SqlServer.Management.Smo.Agent
Ensamblado:  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Sintaxis

'Declaración
Public NotInheritable Class Job _
    Inherits AgentObjectBase _
    Implements IAlterable, ICreatable, IDroppable, IRenamable,  _
    IScriptable
'Uso
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

El tipo Job expone los siguientes miembros.

Constructores

  Nombre Descripción
Método público Job() Initializes a new instance of the Job class.
Método público 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étodo público 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

Arriba

Propiedades

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

Arriba

Métodos

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

Arriba

Eventos

  Nombre Descripción
Evento público PropertyChanged Represents the event that occurs when a property is changed. (Se hereda de SqlSmoObject.)
Evento público PropertyMetadataChanged Represents the event that occurs when property metadata changes. (Se hereda de SqlSmoObject.)

Arriba

Implementaciones de interfaces explícitas

  Nombre Descripción
Implementación de interfaces explícitasMétodo privado IAlienObject.Discover Discovers any dependencies. No haga referencia directamente a este miembro en el código. Admite la infraestructura de SQL Server. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetDomainRoot Returns the root of the domain. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetParent Gets the parent of this object. No haga referencia directamente a este miembro en el código. Admite la infraestructura de SQL Server. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetPropertyType Gets the type of the specified property. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetPropertyValue Gets the value of the specified property. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. No haga referencia directamente a este miembro en el código. Admite la infraestructura de SQL Server. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado IAlienObject.SetPropertyValue Sets the property value. (Se hereda de SqlSmoObject.)
Implementación de interfaces explícitasMétodo privado ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (Se hereda de SqlSmoObject.)

Arriba

Comentarios

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

Todos los miembros estáticos (compartidos en Microsoft Visual Basic) públicos de este tipo son seguros para operaciones multiproceso. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Ejemplos

Programar tareas administrativas automáticas en el Agente SQL Server

Seguridad para subprocesos

Cualquier miembro público static (Shared en Visual Basic) de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Vea también

Referencia

Espacio de nombres Microsoft.SqlServer.Management.Smo.Agent

Otros recursos

Tareas administrativas automatizadas (Agente SQL Server)

sp_add_job (Transact-SQL)