Nathan
Nathan

Reputation: 219

SQL Server float column is removing .00

We have a client database that is using a float datatype for a column. If I insert 55.01 into it it's fine, but if the value inserted is 55.00 it removes the .00. Does anyone know how I can prevent it from doing this? Ideally they don't want the database altered. Is there anything I can do to this query to fix it?

Insert into print_receipt (box_number) values (55.00)

Upvotes: 0

Views: 2952

Answers (1)

JNK
JNK

Reputation: 65157

If you all you want is a trailing 00, there's no need to change the database since it's already accurate.

Change your presentation layer, or just add a cast to your SELECTs:

select CAST(CAST(55.00 as float) as decimal (10,2))

Upvotes: 6

Related Questions