Sql Server using DateTime as Primary Key

前端 未结 4 1966
被撕碎了的回忆
被撕碎了的回忆 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条回答
  •  长发绾君心
    2021-01-02 00:40

    In SQL Server 2008, use DATETIME2, not DATETIME. You can achieve upto 100 nanosecond precision in SQL Server 2008.

    If you sometimes need to record more than one row for a given time, however infrequently, then I'm not sure what you are trying to achieve by making the date and time into a key. Important criteria for choosing keys are Familiarity, Simplicity and Stability. On that basis, assuming it does make sense for your requirements, a date and time seems like a sensible choice.

提交回复
热议问题