Blank (empty string) in Primary key

  • Can we have blank value in Primary key field? Two fields are chosen as Primary Key for this table but the issue is at any given time one value will be blank when other is populated. Does sql server still order the records based on these keys? (Clustered index). Or should I just go about adding ID (identity)?

  • SQL_Surfer (4/29/2014)


    Can we have blank value in Primary key field?

    Yes. It's a value like any other.

    Does sql server still order the records based on these keys? (Clustered index).

    Clustered indexes do not enforce physical order and do not enforce order of data returned, no matter what your key is.

    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

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

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