views:

39

answers:

3

I have a field in a table as nvarchar(10), which is used to store a value in pennies. For example, $23.50 is stored as "2350".

I need to return this value to the program in Money format. How would I do that in the Select statement?

+1  A: 
 cast(cast (pennies as numeric(16,2))/100 as money)
James Curran
A: 
Select convert(money, field/100, 0) from table
websch01ar
No. This will round the result. 101 comes out as 1.00 instead of 1.01. If you divide field by 100.0 instead, then you're OK.
Joe Stefanelli
I did not see that the pennies were being removed. Good catch.
websch01ar
+1  A: 
SELECT CAST (IntAmount / 100.00 as MONEY)
bobs