INCLUDE on primary key

  • Is it possible to use the INCLUDE option on a Primary Key? If so, what is the syntax? I can't seem to locate it.

    Thanks

  • To my knowledge you cant even if the PK is nonclustered.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • I was afraid of that..thanks.

  • Constraints can't have includes or filters, that's pk or unique constraints.

    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
  • Go ahead, Gail, shatter my dreams. 🙂

  • A unique index where all key columns are non-null will achieve effectively the same thing as having a nonclustered PK on those same key columns plus you can add your included columns. However that may not satisfy some things like transactional replication requirements. Just a thought though in case you needed an option.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

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

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