Table.ID Table.ID Table.ID Property

Definition

Gets the ID value that uniquely identifies the table.

public:
 property int ID { int get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcProperty(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.Standalone | Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.SqlAzureDatabase)]
public int ID { get; }
Public ReadOnly Property ID As Integer
Property Value

An Int32 value that specifies the ID value that uniquely identifies the table.

Implements
ID

Examples

The following code example shows how to list the ID value 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 ID of the " + tb.Name + " table is " + tb.ID.ToString());  
}  

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 ID of the" $tb.Name "table is" $tb.ID  
}  

Applies to