EnumForeignKeys 方法
列舉在其中資料表是以外部索引鍵做為參考形式的主索引鍵清單。
命名空間: Microsoft.SqlServer.Management.Smo
組件: Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)
語法
'宣告
Public Function EnumForeignKeys As DataTable
'用途
Dim instance As Table
Dim returnValue As DataTable
returnValue = instance.EnumForeignKeys()
public DataTable EnumForeignKeys()
public:
DataTable^ EnumForeignKeys()
member EnumForeignKeys : unit -> DataTable
public function EnumForeignKeys() : DataTable
範例
The following code example demonstrates how to enumerate a list of the primary keys that reference the table as a foreign key.
C#
Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2008R2"];
foreach (Table tb in db.Tables)
{
tb.EnumForeignKeys();
}
Powershell
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2008R2")
foreach ($tb in $db.Tables)
{
$tb.EnumForeignKeys()
}