Reports information about a primary, foreign, or common key of a particular table or view, or about all keys in the current database.
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.
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:
keytype object related_object object_keys related_keys ------- ------- -------------- --------------- -------------- primary authors -- none -- au_id,*,*,*,*,*,*,* *,*,*,*,*,*,*,* foreign titleauthor authors au_id,*,*,*,*,*,*,* au_id,*,*,*,*,*, *,*
sp_helpkey lists information about all primary, foreign, and common key definitions that reference the table tabname or, if tabname is omitted, about all the keys in the database. Define these keys with the sp_primarykey, sp_foreignkey, and sp_commonkey system procedures.
sp_helpkey does not provide information about the unique or primary key integrity constraints defined by a create table statement. Use sp_helpconstraint to determine what constraints are defined for a table.
Create keys to make explicit a logical relationship that is implicit in your database design so that applications can use the information.
If you specify an object name, sp_helpkey follows the Adaptive Server rules for finding objects:
If you do not specify an owner name, and you own an object with the specified name, sp_helpkey reports on that object.
If you do not specify an owner name, and you do not own an object of that name, but the Database Owner does, sp_helpkey reports on the Database Owner’s object.
If neither you nor the Database Owner owns an object with the specified name, sp_helpkey reports an error condition, even if an object with that name exists in the database for a different owner.
If both you and the Database Owner own objects with the specified name, and you want to access the Database Owner’s object, specify the name in the form dbo.objectname.
Qualify objects that are owned by database users other than yourself and the Database Owner with the owner’s name, as in “mary.myproc”.
Any user can execute sp_helpkey.
Commands create trigger
System procedures sp_commonkey, sp_foreignkey, sp_primarykey