null value in unique constraint

  • Hi,I have a question that I can't find the answer anywhere...I know that in sql2005 the unique constraint can keep just one null record,but I don't know that why it can keep one null and the usage of this null record in sql2005??...if someone know the answer please tell it....thanks in advance

  • There's no real use. It's just that within unique indexes is the only place where nulls are considered the same. Unique indexes and unique constraints only allow a single null. Irritating, but that's how it it.

    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
  • GilaMonster (8/29/2009)


    It's just that within unique indexes is the only place where nulls are considered the same.

    NULLs are also considered 'the same' by GROUP BY, DISTINCT, UNION, EXCEPT, INTERSECT...and probably others 😛

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

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