Primary/Foreign Key Constraints.Relations

  • Hey all,

    I am trying to search my DB for any primary and foreign key constraints and or relations for a specific tables. how would i find this out? im a noob, sorry.

     

    Thanks

  • You can probably query sysobjects where xtype is in the primary/foreign key constraints (check BOL for the code) and join against sysdepends.

    Sorry, not near a SQL server right now or I'd test it and post it.

  • hi

    Try the sysconstraints table.

    "Keep Trying"

  • Hi duddy Just check the following query

    and enjoy................

    Select * from information_schema.table_constraints constraints2

    Select * from information_schema.Constraint_Column_Usage

    Select * from information_schema.referential_constraints fkeys

    Select * from information_schema.table_constraints constraints2

    Shashi Kant(MCA)

  • try using sp_pkeys or sp_fkeys to get the primary and foreign key relationships.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

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

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