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)
 How to limit the precision of money type

Author  Topic 

JeffS23
Posting Yak Master

212 Posts

Posted - 2008-01-01 : 15:18:59
I need to apply the 4% increase to the product price. The original product price is son=mthing like this:

22.88 (money data type). After 4% increase, it becomes 23.7952 (money data type).

How do I make the price to be 23.80 in SQL?

Code I use: UnitPrice = UnitPrice * 1.04

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-01-01 : 15:49:18
declare @up money
set @up = 22.88

select round(@up * 1.04, 2)
select convert(decimal(4, 2), round(@up * 1.04, 2))

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

georgev
Posting Yak Master

122 Posts

Posted - 2008-01-01 : 15:51:39
[CODE]
DECLARE @x table (cash money)

INSERT INTO @x(cash) VALUES(22.88)

UPDATE @x
SET cash = cash * 1.04

SELECT cash
, Round(cash, 2)
FROM @x
[/CODE]


George
<3Engaged!
Go to Top of Page
   

- Advertisement -