CAST(DATETIME AS DATE) over WHERE clause

后端 未结 3 666
心在旅途
心在旅途 2021-01-06 12:31

I\'m using SQL Server 2012 and I would like to know if I write the sentence:

SELECT MyDateTimeColumn 
FROM MyTable
WHERE CAST(MyDateTimeColumn AS DATE) = \'         


        
3条回答
  •  轮回少年
    2021-01-06 13:15

    In SQL 2008+, CAST(foo AS date) is sargable, along with a few other manipulations. Look at the execution plans in the sqlfiddle.

    SQL Fiddle Demo

提交回复
热议问题