• Well, the problem with that is when the table is created, I do a

    create table(

    TableIdCol...

    primaryKey(TableIdCol)

    )

    So, now you've got a good reason to care for the names of your object yourself.

    There are more than one way to skin that cat. You can use one of the above or

    sp_helpconstraint or

    USE NORTHWIND

    SELECT

     T1.TABLE_NAME

     , T2.CONSTRAINT_NAME

    FROM

     INFORMATION_SCHEMA.TABLES AS T1

    INNER JOIN

     INFORMATION_SCHEMA.TABLE_CONSTRAINTS T2

    ON

     T1.TABLE_NAME = T2.TABLE_NAME

    WHERE

      CONSTRAINT_TYPE = 'PRIMARY KEY'

    AND

     TABLE_TYPE = 'BASE TABLE'

    AND T1.TABLE_NAME = 'Orders'

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]