Share via


Table.FileGroup Property

Gets or sets the filegroup in which the table is stored.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

Syntax

'Declaration
<SfcPropertyAttribute(SfcPropertyFlags.None Or SfcPropertyFlags.ReadOnlyAfterCreation Or SfcPropertyFlags.Standalone)> _
Public Property FileGroup As String 
    Get 
    Set
'Usage
Dim instance As Table 
Dim value As String 

value = instance.FileGroup

instance.FileGroup = value
[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.ReadOnlyAfterCreation|SfcPropertyFlags.Standalone)]
public string FileGroup { get; set; }
[SfcPropertyAttribute(SfcPropertyFlags::None|SfcPropertyFlags::ReadOnlyAfterCreation|SfcPropertyFlags::Standalone)]
public:
property String^ FileGroup {
    String^ get ();
    void set (String^ value);
}
[<SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.ReadOnlyAfterCreation|SfcPropertyFlags.Standalone)>]
member FileGroup : string with get, set
function get FileGroup () : String 
function set FileGroup (value : String)

Property Value

Type: System.String
A String value that specifies the filegroup in which the table is stored.

Remarks

The FileGroup property is set prior to the creation of the table. After the table is created, the property is read-only.

Examples

The following code example shows how to create a new table and display the time and date that it was created on the console.

C#

Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2012"];

Table tb = new Table(db, "Test Table");
Column col1 = new Column(tb, "Name", DataType.NChar(50));
Column col2 = new Column(tb, "ID", DataType.Int);

tb.Columns.Add(col1); 
tb.Columns.Add(col2); 
tb.Create();

Console.WriteLine("The table is part of the " + tb.FileGroup.ToString() + " file group.");

Powershell

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

#Create the Table
$tb = new-object Microsoft.SqlServer.Management.Smo.Table($db, "Test Table")
$col1 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "Name", [Microsoft.SqlServer.Management.Smo.DataType]::NChar(50))
$col2 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "ID", [Microsoft.SqlServer.Management.Smo.DataType]::Int)
$tb.Columns.Add($col1)
$tb.Columns.Add($col2)
$tb.Create()

Write-Host "The table is part of the" $tb.FileGroup "file group."

See Also

Reference

Table Class

Microsoft.SqlServer.Management.Smo Namespace

Other Resources

Tables

CREATE TABLE (Transact-SQL)