Looking for PK's in Tables

  • I've asked our DBA to add three Db's to server b from server a, but just learned that if any tables don't have primary keys don't get replicated, so I need to go thru each table and make sure which do or do not have PK's.

    Is there some syntax outhere where I can run it within a Db and return all PK's for all table in that Db?

    Or something to that effect.

    thx,

    john

  • SELECT name as TableName, ObjectProperty(object_id, 'TableHasPrimaryKey') AS HasPrimaryKey

    FROM sys.tables

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Beautiful...thx

Viewing 3 posts - 1 through 3 (of 3 total)

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