how do I view foreign keys with t-sql?

  • I'm a unix guy that needs to do a few things on sql server and I can't figure out how to view all foreign keys on a table with t-sql (NOT em or query analyzer)

    Anyone have any idea how to do this?

  • How do you connect to SQL Server from Unix? What language/tools/libriaries do you use ?


    * Noel

  • I'm not connection from unix, I was trying to say that I'm not a novice, but I'm unfamiliar with MS products.

    I figured out how to do what I wanted.

    EXEC sp_fkeys @pktable_name = N'tblProducts'

    The odd part of this stored procedure is that you have to supply the table the fk refers to, not the table it's assigned to :/

  • The @fktable_name parameter doesn't work for you?

  • You could use

    sp_helpconstraint tblproducts

    sp_help tblproducts

    This will list you all the foreign keys the table is referring and also other Table referenceing this table.

  • yeah,i was being obtuse :/

    Thanks

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply