Sql – How to show trailing zeroes with float

sql, sql-server, sql-server-2000, tsql

Using SQL Server 2000

zero are not showing while using a float.


insert into table1 values ('01.10')insert into table1 values ('10.50')insert into table1 values ('02.02')


Values (datatype is float)01.110.502.02...

How to show the last zero's also

Expected Output

Values (datatype is float)


Best Solution

Why are you using FLOAT? I find that in a lot of cases people use FLOAT when they don't understand its limitations or peculiarities. For storing decimal values with 2 decimal places, I would use decimal instead.

CREATE TABLE #floob(f FLOAT, d DECIMAL(10,2));INSERT #floob SELECT 2.02, 2.02;INSERT #floob SELECT 2.7, 2.7;INSERT #floob SELECT 1.5, 1.5;SELECT f, f_as_d = CONVERT(DECIMAL(10,2), f), d FROM #floob;


f        f_as_d   d------   ------   ------2.02     2.02     2.022.7      2.70     2.701.5      1.50     1.50