Get only two decimal points in a money data type in SQL Server

SELECT ROUND(123.4567, 2)` gives me `123.4600` 

But I need 123.46 .

The field data type is money.

Decision:

 <%# DataBinder.Eval(Container.DataItem, "FieldName","{0:0.00}") %> 
+6
sql-server tsql rounding sql-server-2005
source share
5 answers

If applicable, format at the presentation level, and not on the data layer, that is, read all the data and wipe it later (for example, on a C # client)

+9
source share
 SELECT CAST(ROUND(123.4567, 2) AS MONEY) 

Will do what you after

+16
source share
+1
source share
 SELECT FORMAT(123.4567,'N2') 

It will help you get out

0
source share

@IsmailS - for me, a larger image is the maximum possible format of a data server format, especially when it is something as simple as an embedded listing. This gives less clutter in your other code. For example, casting price , money field:

select CAST(Price as numeric(17,2)) Price from PriceTable

YMMV - This is my personal experience.

0
source share

All Articles