I have a view which needs to return type decimal for columns stored as float.
I can cast each column to decimal as follows:
, CAST(Field1 as decimal) Fi
12, 12 means no digits before the decimal separator: 12 digits in total, 12 of them being after the period.
12, 12
12
Use a more appropriate range, say:
DECLARE @var FLOAT = 100 SELECT CAST(@var as decimal(20,12))
which gives you 8 digits before the separator, or adjust it as needed.
8