Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Math Function to Round a Decimal

Author  Topic 

hismightiness
Posting Yak Master

164 Posts

Posted - 2009-08-19 : 15:39:24
Is there a mathematical function that will round a decimal number to 2 decimal places? For example:

Change this: 12345.62764

To this: 12345.63

... OR ...

Change this: 12345.61247

To this: 12345.61

- - - -
- Will -
- - - -
http://www.willstrohl.com

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-19 : 15:44:47
see which option works best for you:

select round(n, 2) as [round]
,convert(decimal(7,2), n) [convert]
from (
select 12345.62764 as n
) d

output:
round convert
--------------------------------------- ---------------------------------------
12345.63000 12345.63


EDIT:
Check out what other math functions there are in Books Online:
Mathematical Functions (Transact-SQL)


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -