1

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 ?

2
  • If you use row compression internally the data will be stored according to the size required. Are you not mixing up data presentation & storage ? A decimal datatype is defined with a fixed number of digits before and after the decimal point (precision & scale in the documentation). See docs.microsoft.com/en-us/sql/t-sql/data-types/… – Stephen Morris - Mo64 Dec 17 '20 at 9:26
  • You could use a view to look at your data, and format the columns up just as you like them. – Paul Dec 17 '20 at 9:49
2

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.