次の方法で共有


Database.FileGroups プロパティ

FileGroup オブジェクトのコレクションを取得します。 各 FileGroup オブジェクトは、データベースで定義されたファイル グループを表します。

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

構文

'宣言
<SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.OneToAny, GetType(FileGroup))> _
Public ReadOnly Property FileGroups As FileGroupCollection 
    Get
'使用
Dim instance As Database 
Dim value As FileGroupCollection 

value = instance.FileGroups
[SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.OneToAny, typeof(FileGroup))]
public FileGroupCollection FileGroups { get; }
[SfcObjectAttribute(SfcContainerRelationship::ChildContainer, SfcContainerCardinality::OneToAny, 
    typeof(FileGroup))]
public:
property FileGroupCollection^ FileGroups {
    FileGroupCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.OneToAny, 
    typeof(FileGroup))>]
member FileGroups : FileGroupCollection
function get FileGroups () : FileGroupCollection

プロパティ値

型: Microsoft.SqlServer.Management.Smo.FileGroupCollection
データベースで定義されたすべてのファイル グループを表す FileGroupCollection オブジェクトです。

説明

このコレクションを使用し、ファイル グループ名を指定することによって、特定のファイル グループを参照できます。 新しいファイル グループをコレクションに追加するには、ファイル グループ コンストラクター FileGroup を呼び出します。

使用例

VB

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server

'Reference the AdventureWorks2012 database.
Dim db As Database
db = srv.Databases("AdventureWorks2012")

'Display all the log files in the database.
Dim lf As LogFile
For Each lf In db.LogFiles
   Console.WriteLine(lf.Name)
Next

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")

Foreach ($lf in $db.LogFiles)
{
   Write-Host $lf.Name
}

関連項目

参照

Database クラス

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

データベース オブジェクトでの作業

ファイルとファイル グループを使用したデータの格納

データベースの作成、変更、および削除

CREATE DATABASE (Transact-SQL)