On two different sql servers I run the following query:
declare @myDatetime as datetime = '2017-07-04 23:42:32.400'
select CAST(@myDatetime AS DECIMAL(20,5))
I get two different results: 42918.98788 and 42918.98787
If I cast to a DECIMAL(20,6) it works fine (42918.987875) but let's say I need to put it in a decimal(20,5).
Where can I found the source of this difference in behaviour when rounding? Is it an option somewhere that rounds the final 5 up or down? Is it a sort of locale, international setting, collation or else? Is it the different verions of SQL (12.0.5000.0 vs 13.0.4202.2)?