Sql-server – Store Decimal values without Trailing Zeros

datatypessql-server-2008

I am using SQL Server 2008 R2 version.

Is there any method to store decimal value in SQL without extra trailing zeros(like Float data type format).

I have created a column with decimal data type with highest precision.

Actual values:

2.50000000
4.55530000
1.85333310

Expected:

2.5
4.5553
1.8533331

Is it possible to store values in above expected format with highest precision ?

Best Answer

The storage of Data shouldn't concern you, as long you have the wanted precision

and representation of the data you can do on your application.

If you want a select that will remove the trailing Zeros

you can use

SELECT convert(DOUBLE PRECISION, 20.10)