Find out foreign key reference table

sybasetable

How to find out all the foreign key reference tables for a table in Sybase by writing a Query .

Best Answer

The system provided sp_helpconstraint should do the trick.

If you want to write your own code then I'd suggest you take a look at the source code for sp_helpconstraint, see where/how it derives the constraint data, then write your own query(s) to generate the desired result set.

To find the source code for sp_helpconstraint you can either look in the installmaster script, or run exec sybsystemprocs..sp_helptext sp_helpconstraint,null,null,showsql.