Trying to discover Foreign Keys of a table using RazorSQL, but when i use this command:
EXEC SP_FKEYS <table_name>
the information is always empty.
Obs: The paste of the columns table that have foreign key columns
Trying to discover Foreign Keys of a table using RazorSQL, but when i use this command:
EXEC SP_FKEYS <table_name>
the information is always empty.
Obs: The paste of the columns table that have foreign key columns
NOTE: I'm assuming you're using the (Sybase) ASE product ...
If by 'foreign key' you're referring to referential integrity (RI) foreign key constraints, try:
exec sp_helpconstraint <table_name>
sp_helpconstraint
will display all primary, unique, foreign key and check constraints on a table. [These constraints are created via the create table
/alter table
commands.]
The sp_fkeys
/sp_pkeys
procs are a throwback to earlier times when:
ASE did not have table-level RI constraints so ...
triggers had to be used to enforce RI requirements and therefore ...
sp_fkeys
/sp_pkeys
were used to 'document' these trigger-based RI
constraints so that 3rd party apps had a means of querying the
database for RI constraint details
The accuracy of the results from running sp_fkeys
/sp_keys
is dependent on whether or not the dbo/table owner remembers to 'document' these RI constraints.
There is no relationship between actual/enforced RI constraints (created via the create table
/alter table
commands) and 'documented' RI constraints (created via sp_fkeys
/sp_pkeys
invocations).