次の方法で共有


JobServer プロパティ

SQL Server のインスタンスに関連付けられた SQL Server エージェントを取得します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
<SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)> _
Public ReadOnly Property JobServer As JobServer
    Get
'使用
Dim instance As Server
Dim value As JobServer

value = instance.JobServer
[SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)]
public JobServer JobServer { get; }
[SfcObjectAttribute(SfcObjectRelationship::Object, SfcObjectCardinality::One)]
public:
property JobServer^ JobServer {
    JobServer^ get ();
}
[<SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)>]
member JobServer : JobServer
function get JobServer () : JobServer

プロパティ値

型: Microsoft.SqlServer.Management.Smo.Agent. . :: . .JobServer
SQL Server のインスタンスに関連付けられた SQL Server エージェントを示す JobServer オブジェクトです。

説明

JobServer オブジェクトは、SQL Server エージェントを表します。JobServer オブジェクトを使用して、SQL Server エージェント ジョブ、オペレーター、および警告を参照できます。JobServer オブジェクトを使用して、SQL Server エージェント設定を表示または変更することもできます。

使用例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Define an Alert object variable by supplying the SQL Agent and the name arguments in the constructor.
Dim al As Alert
al = New Alert(srv.JobServer, "Test_Alert")
'Specify the performance condition string to define the alert.
al.PerformanceCondition = "SQLServer:General Statistics|User Connections||>|3"
'Create the alert on the SQL Agent.
al.Create()
'Define an Operator object variable by supplying the SQL Agent and the name arguments in the constructor.
Dim op As [Operator]
op = New [Operator](srv.JobServer, "Test_Operator")
'Set the net send address.
op.NetSendAddress = "NetworkPC"
'Create the operator on the SQL Agent.
op.Create()
'Run the AddNotification method to specify the operator is notified when the alert is raised.
al.AddNotification("Test_Operator", NotifyMethods.NetSend)

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$al = new-object Microsoft.SqlServer.Management.Smo.Agent.Alert($srv.JobServer, "Test Alert")
$al.PerformanceCondition = "SQLServer:General Statistics|User Connections||>|3"
$al.Create()
$op = new-object Microsoft.SqlServer.Management.Smo.Agent.Operator($srv.JobServer, "Test Operator")
$op.NetSendAddress = "NetworkPC"
$op.Create()
$al.AddNotification("Test Operator", [Microsoft.SqlServer.Management.Smo.Agent.NotifyMethods]::NetSend)