Thursday 14 October 2010

Implicit column Conversions

I came across an excellent post ' Finding Implicit Column Conversions in the Plan Cache ' by Jonathan Kehayias today and had to try out his script to see if we had implicit conversions going on.
The only find was one of my most commonly used routines where I get the DATE portion from a DATETIME column.

I did do this -

SELECT CAST(DATEDIFF(D, 0, GETDATE()) AS DATETIME)

To prevent an implicit conversion occuring (ok, it's not exactly a massive overhead), I've changed the code to -

SELECT DATEADD(dd, DATEDIFF(dd, '1900-01-01', GETDATE()),'1900-01-01')


Further reading :



No comments: