Condividi tramite


Classe Job

The Job class represents a Microsoft SQL Server Agent job.

Gerarchia di ereditarietà

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

Spazio dei nomi  Microsoft.SqlServer.Management.Smo.Agent
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Sintassi

'Dichiarazione
Public NotInheritable Class Job _
    Inherits AgentObjectBase _
    Implements IAlterable, ICreatable, IDroppable, IRenamable,  _
    IScriptable
'Utilizzo
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

Nel tipo Job sono esposti i membri seguenti.

Costruttori

  Nome Descrizione
Metodo pubblico Job() Initializes a new instance of the Job class.
Metodo pubblico 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.
Metodo pubblico 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

In alto

Proprietà

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

In alto

Metodi

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

In alto

Eventi

  Nome Descrizione
Evento pubblico PropertyChanged Represents the event that occurs when a property is changed. Ereditato da SqlSmoObject.
Evento pubblico PropertyMetadataChanged Represents the event that occurs when property metadata changes. Ereditato da SqlSmoObject.

In alto

Implementazioni esplicite dell'interfaccia

  Nome Descrizione
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.Discover Discovers any dependencies. Non fare riferimento direttamente a questo membro nel codice. Supporta l'infrastruttura di SQL Server. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.GetDomainRoot Returns the root of the domain. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.GetParent Gets the parent of this object. Non fare riferimento direttamente a questo membro nel codice. Supporta l'infrastruttura di SQL Server. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.GetPropertyType Gets the type of the specified property. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.GetPropertyValue Gets the value of the specified property. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Non fare riferimento direttamente a questo membro nel codice. Supporta l'infrastruttura di SQL Server. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato IAlienObject.SetPropertyValue Sets the property value. Ereditato da SqlSmoObject.
Implementazione esplicita dell'interfacciaMetodo privato ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. Ereditato da SqlSmoObject.

In alto

Osservazioni

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

Tutti i membri statici pubblici (Shared in Microsoft Visual Basic) di questo tipo sono sicuri per le operazioni a thread multipli. Non è invece garantita la sicurezza dei membri dell'istanza.

Esempi

Pianificazione delle attività amministrative automatiche in SQL Server Agent

Protezione dei thread

I membri static (Shared in Visual Basic) pubblici di questo tipo sono affidabili. Non è invece garantita la sicurezza dei membri dell'istanza.

Vedere anche

Riferimento

Spazio dei nomi Microsoft.SqlServer.Management.Smo.Agent

Altre risorse

Automatizzazione delle attività amministrative (SQL Server Agent)

sp_add_job (Transact-SQL)