Round function in Replace Sum query

Hello SQL maniacs,

I have a query which is retrieving data from a view.
In this query I use the following line:

replace (sum (column1), ',', '.') as amountpaid,

But it looks like the value I get is rounded by 1 decimal. Cause when I sum the values from the view myself than I get for example 100,86. but when I use the query I get 100,9

Can someone tell me how I get a value with 2 decimals with this query.
Thanx.

What is the data type of column1?

The column is a 'Varchar' type

Confirm ? You can't SUM() a varchar column.

Are you using MS SQL Server ?

Sorry, i was looking in the wrong column. It is a float type.
I'm using MSSQL2005 server

try

replace (sum (convert(decimal(10,2), column1)), ',', '.') as amountpaid

Thanx !!
You are an hero !!

Why are you replacing Comma with Period? Sounds like the Locale (controlling the numeric format you want to display the amount in) is wrong. If you change Numeric to String then you lose ability to sort etc. and may also have issues with downstream processes trying to re-parse the data. Better to transmit numeric in native format and let the "far end" deal with the display issue.

But of course I have not idea why you are needing to make this change within SQL :slight_smile: and there are also good reasons to choose to do that. I just wanted to check that your solution is the best for the actual problem you face.