Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How to differ datetime2(0) vs datetime2(2)?

Asked by Anna Ball Jul 19, 2021 297 views 1 answer
Share

About this question

 According to the documentation datetime2 (Transact-SQL): Storage size bytes for precisions less than bytes for precisions 3 and 4. All other precisions require 8 bytes. The size of datetime2(0), datetime2(1), datetime2(2) use the same amount of storage (6 bytes). Would I be correct in saying that I might as well go with datetime2(2) and gain the benefit of the precision without any additional size costs?

Please note: This column is indexed with the PK to form a compound clustered index (used for table partitioning) I do not care about milliseconds

Would datetime2(0) be more CPU efficient when used in a where clause, or when seeking through an index? This is a massive table, so the smallest optimization will make a big difference.

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.