Sql Server using DateTime as Primary Key

前端 未结 4 1971
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 00:10

Hi my questions is similar to:

MySQL: Using DATETIME as primary key

But I\'m specifically interested in Sql Server and I want to approach the question practi

4条回答
  •  萌比男神i
    2021-01-02 00:51

    In order for infrequent collisions to be acceptable you really cannot use the timestamp as there will be collisions.

    You could code around collisions by using a smart procedure that modifies the datatime slightly, but why bother when an index on the timestamp would suffice and be far easier to implement.

    This article is informative on precision issues specific to C# however.

提交回复
热议问题