Server.Roles プロパティ

ServerRole オブジェクトのコレクションを表します。 各 ServerRole オブジェクトは、SQL Server のインスタンスで定義されたロールを表します。

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

構文

'宣言
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(ServerRole))> _
Public ReadOnly Property Roles As ServerRoleCollection 
    Get
'使用
Dim instance As Server 
Dim value As ServerRoleCollection 

value = instance.Roles
[SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(ServerRole))]
public ServerRoleCollection Roles { get; }
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(ServerRole))]
public:
property ServerRoleCollection^ Roles {
    ServerRoleCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(ServerRole))>]
member Roles : ServerRoleCollection
function get Roles () : ServerRoleCollection

プロパティ値

型: Microsoft.SqlServer.Management.Smo.ServerRoleCollection
SQL Server のインスタンスで定義されたすべてのロールを表す ServerRoleCollection オブジェクトです。

説明

Roles プロパティは ServerRoleCollection オブジェクトを参照しています。 このコレクションを使用して、SQL Server のインスタンスの固定サーバー ロールを参照できます。

使用例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Display the fixed server roles.
Dim sr As ServerRole
For Each sr In srv.Roles
   Console.WriteLine(sr.Name)
Next

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
foreach ($sr in $srv.Roles)
{
   Write-Host $sr.Name
}

関連項目

参照

Server クラス

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

コレクションの使用

プロパティの設定

サーバーの管理