다음을 통해 공유


Table.EnumForeignKeys 메서드

Enumerates a list of primary keys in which the table is referenced as a foreign key.

네임스페이스:  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

반환 값

유형: System.Data.DataTable
A DataTable system object value that contains a list of information about where this table is referenced as a foreign key. The table describes the different columns of the returned DataTable.

Column

Data type

Description

Table_Schema

String

The name of the schema associated with the table that contains the foreign key.

Table_Name

String

The name of the table that contains the foreign key.

Name

String

The name of the foreign key.

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["AdventureWorks2012"];

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("AdventureWorks2012")

foreach ($tb in $db.Tables)
{
   $tb.EnumForeignKeys()
}

참고 항목

참조

Table 클래스

Microsoft.SqlServer.Management.Smo 네임스페이스

관련 자료

테이블

CREATE TABLE(Transact-SQL)