sp_helpkey

Description

Reports information about a primary, foreign, or common key of a particular table or view, or about all keys in the current database.

Syntax

sp_helpkey [tabname]

Parameters

tabname

is the name of a table or view in the current database. If you do not specify a name, the procedure reports on all keys defined in the current database.

Examples

Example 1

Displays information about the keys defined in the current database. The “object_keys” and “related_keys columns refer to the names of the columns that make up the key:

sp_helpkey
keytype object      related_object object_keys         related_keys 
------- -------     -------------- ---------------     --------------
primary authors     -- none --     au_id,*,*,*,*,*,*,*  *,*,*,*,*,*,*,*
foreign titleauthor authors        au_id,*,*,*,*,*,*,* au_id,*,*,*,*,*,
                                                               *,*

Usage

Permissions

Any user can execute sp_helpkey.

See also

Commands create trigger

System procedures sp_commonkey, sp_foreignkey, sp_primarykey