SQL – rounding to nearest 5

Had a requirement to round some price values to the nearest £5 in a SQL stored proc. It’s easy to round to the nearest 10 using a negative value for the length parameter of the ROUND function i.e. [sql]select round(12, -1)[/sql] returns 10 [sql]select round(16, -1)[/sql] returns 20 but length must be of type tinyint, Read more about SQL – rounding to nearest 5[…]

Power and Deception of CTEs

This is a reprint of an article of mine that appeared on SQLServerCentral.com in December 2008 Introduction A customer of mine had a performance problem with a stored procedure that uses Common Table Expressions (CTEs). The performance had gone from sub second to 10-12 secs, and the approach that was being taken to diagnose and Read more about Power and Deception of CTEs[…]