Export (0) Print
Expand All
Expand Minimize

Table.Owner Property

Gets or sets the owner of the table.

This API is not CLS-compliant. 

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

[SfcReferenceAttribute(typeof(User), "Server[@Name = '{0}']/Database[@Name = '{1}']/User[@Name = '{2}']", 
	)]
[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.SqlAzureDatabase|SfcPropertyFlags.Design|SfcPropertyFlags.Matrix)]
[SfcReferenceAttribute(typeof(DatabaseRole), "Server[@Name = '{0}']/Database[@Name = '{1}']/Role[@Name = '{2}']", 
	)]
[SfcReferenceAttribute(typeof(ApplicationRole), "Server[@Name = '{0}']/Database[@Name = '{1}']/ApplicationRole[@Name = '{2}']", 
	)]
[CLSCompliantAttribute(false)]
public string Owner { get; set; }

Property Value

Type: String
A String value that specifies the owner of the table.

Implements

ITableOptions.Owner

The following code example lists the owners of each table in the AdventureWorks2012 database.

C#

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

foreach (Table tb in db.Tables) 
{
   Console.WriteLine("The " + tb.Name + " table is owned by " + tb.Owner);
}

Powershell

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

Foreach ($tb in $db.Tables) 
{
   Write-Host "The" $tb.Name "table is owned by" $tb.Owner
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft