1

I'm adding float data in my sql table, but even though I'm adding the value 201.95, the table shows 201.949996... (a lot of decimal digits). Is there any way to handle this ?, since I only want two digits as decimal numbers.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Osman Esen
  • 1,704
  • 2
  • 21
  • 46

2 Answers2

2

You may have to re-create the table with the column using DECIMAL(x, 2) as data-type.

Where x is any value defined in below article.

Decimal and Numeric (Transact-SQL)

0

Good to use Decimal or numeric(18,2) (18 is total length and 2 for decimal value) check this

declare @temp float = '201.9500011'
select @temp

declare @temp1 numeric(18,2) = '201.9500011'
select @temp1

How to store decimal values in SQL Server?

Community
  • 1
  • 1
Ajay2707
  • 5,690
  • 6
  • 40
  • 58