So it appears that if you
CAST(field1 as decimal) field1
this will automatically add rounding.
The original is defined as:
field1 type:float length:8 prec:53
I need to cast it to decimal, because I need my Entity Framework layer to generate this field as decimal (instead of double).
Is there a way to cast it as decimal, so that it preserves original precision, and doesn't round?
I would like to avoid having to declare the precision in the cast, because:
This question is related to
sql
sql-server
casting
cast (field1 as decimal(53,8)
) field 1
The default is: decimal(18,0)
Try SELECT CAST(field1 AS DECIMAL(10,2)) field1
and replace 10,2
with whatever precision you need.
Source: Stackoverflow.com