简体   繁体   中英

SQL Server 2014 Round Function

I'm using SQL Server 2014 and I read this MSDN page for ROUND function: ROUND (Transact-SQL)

When I run this example from above page, the result of my is not same as MSDN result:

MSDN:

SELECT ROUND(123.4545, 2)  -->  123.45 

My result:

 SELECT ROUND(123.4545, 2)  -->  123.4500

There are two extra zeros in my result. Where is the problem? I want to have MSDN result.

Thanks

You have given 4 decimals so you would get results in 4 decimals.

Try like this,

SELECT convert(DECIMAL(8, 2), ROUND(123.4545, 2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM