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()
}