Sql – How to store decimal values in SQL Server

decimalsqlsql servertypes

I'm trying to figure out decimal data type of a column in the SQL Server. I need to be able to store values like 15.5, 26.9, 24.7, 9.8, etc

I assigned decimal(18, 0) to the column data type but this not allowing me to store these values.

What is the right way to do this?

Best Answer

DECIMAL(18,0) will allow 0 digits after the decimal point.

Use something like DECIMAL(18,4) instead that should do just fine!

That gives you a total of 18 digits, 4 of which after the decimal point (and 14 before the decimal point).