Keys Collection (SQL-DMO)

The Keys collection contains Key objects referencing referential integrity declarations that are implemented by Microsoft® SQL Server™ PRIMARY KEY and FOREIGN KEY constraints.

Remarks

With the Keys collection, you can:

For more information about using the Keys collection to create SQL Server PRIMARY KEY and FOREIGN KEY constraints, see Key Object.

To remove a SQL Server constraint implementing key-based referential integrity

    oTable.Keys.Remove("FK_Order_Details_Products")

  

When using the Item or Remove method, the Keys collection supports member identification using either name or ordinal reference syntax. For example:

Set oKey = oTable.Keys("PK_Order_Details")

  

Or:

Set oKey = oTable.Keys(2)

  


Note Creating or removing SQL Server constraints implementing key-based referential integrity by using the Keys collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the fixed role db_ddladmin or a role with greater privilege.


Methods
Add Method Refresh Method
Item Method Remove Method (Collections)

Properties

Count Property


(c) 1988-98 Microsoft Corporation. All Rights Reserved.