1 Version 4.0 -- 1/15/89 sp_dropkey
______________________________________________________________________
NAME: sp_dropkey
FUNCTION:
Removes a key from the syskeys table that had been defined using
sp_primarykey, sp_foreignkey, or sp_commonkey.
SYNTAX:
sp_dropkey keytype, tabname [, deptabname]
EXAMPLES:
1) sp_dropkey primary, employees
sp_dropkey Version 4.0 -- 1/15/89 2
______________________________________________________________________
Drops the primary key for the table employees. Any foreign
keys that were dependent on the primary key on employees are
also dropped.
2) sp_dropkey common, employees, projects
Drops the common keys between the employees and projects
tables.
PARAMETERS:
keytype - is the type of key to be dropped. The keytype must be
primary, foreign, or common.
tabname - is the name of the table that contains the key to be
dropped.
deptabname - is used if the keytype is foreign. It is the name
of the dependent table in the key to be dropped-the table
that contains the foreign key. If the keytype is primary,
3 Version 4.0 -- 1/15/89 sp_dropkey
______________________________________________________________________
this parameter is ignored, since primary keys have no depen-
dent table.
COMMENTS:
o Executing sp_dropkey deletes the specified key from syskeys.
o Only the owner of a table may drop a key on that table.
o Dropping a primary key automatically drops any foreign keys
associated with it. Dropping a foreign key has no effect on a
primary key specified on that table.
o Keys are created to make explicit a logical relationship that
is implicit in your database design. This information can be
used by an application program.
o Executing sp_commonkey, sp_primarykey, or sp_foreignkey adds
the key to the syskeys system table. To display a report on
the keys that have been defined, execute sp_helpkey.
sp_dropkey Version 4.0 -- 1/15/89 4
______________________________________________________________________
MESSAGES:
The keytype parameter should specify the type of key to drop.
You can't drop keys on tables in other databases.
The tabname supplied isn't a table or view in the current data-
base.
You aren't the owner of tabname, so you can't drop the key.
tabname has no primary key defined.
The primary key was successfully dropped. It has been deleted
from syskeys.
When a primary key is dropped, any foreign keys that depend on it
are also dropped.
When dropping a foreign or common key, both the tabname and dep-
tabname tables must be named.
The name supplied for the deptabname parameter isn't a table or
view in the current database.
tabname has no foreign key defined.
5 Version 4.0 -- 1/15/89 sp_dropkey
______________________________________________________________________
The foreign key has been successfully dropped. It has been
deleted from syskeys.
There are no common keys between the tabname and deptabname
tables. No action was taken.
The common keys were successfully dropped. They have been
deleted from syskeys.
PERMISSIONS:
Execute permission to owner of tabname.
TABLES USED:
syskeys, sysobjects
SEE ALSO:
sp_commonkey, sp_foreignkey, sp_helpkey, sp_primarykey