views:

36

answers:

2

SELECT ROUND(123.4567, 2) gives me 123.4600.

But I need 123.46.

Data type of field is money.

SOLUTION
<%#DataBinder.Eval(Container.DataItem, "FieldName","{0:0.00}")%>

+8  A: 
SELECT CAST(ROUND(123.4567, 2) AS MONEY)

Will do what you are after

Ardman
This works, but when I assign the value to a field in Repeater on my .aspx page, it again show two trailing zeros. I'm using Linq to sql.
Ismail
You could use a ToString() in your repeater specifying the format to how you want it.
Ardman
+1 thanks for your answer. Your answer is also right looking at my question. But @abatishchev tried to solve the bigger problem instead of just answering my question. That's why, I've accepted his answer.
Ismail
+5  A: 

If applicable, format on the view layer, not on the data layer, i.e. read all the data and truncate it later (if you're using DB from without - in C# client, etc)

abatishchev
+1. Binding it like this in repeater worked `<%#DataBinder.Eval(Container.DataItem, "FieldName","{0:0.00}")%>`. Thanks for directing me to solve the actual problem.
Ismail
@Ismail: Glad it helped! :) P.S. I had the same problems - http://stackoverflow.com/questions/1308259/rounding-down-decimal14-3-to-third-decimal-digit-in-sql-2008 http://stackoverflow.com/questions/2938296/remove-trailing-zeros-from-decimal-in-sql-server
abatishchev