May 21, 2012 at 5:53 am
I have some values in a column that are of the smallint datatype. Example values are 100 and 150. What do I need to with my TSQL to get these values to come out as 1.00 and 1.50?
I have tried:
CAST(myval as DECIMAL) returns same value as before (150)
CAST(myval as MONEY) returns 150.00
Doing CONVERT returns the same values respectively as above.
CAST(myval AS DECIMAL(3,2) returns an Arthimetic Overflow error.
Any and all help will be greatly appreciated.
Thanks
May 21, 2012 at 5:57 am
I give up to easily sometimes...
Using CAST(myval AS DECIMAL)/100 is giving me what I need.
Thanks
May 21, 2012 at 6:37 am
You could just devide by 100.0:
declare @i int
set @i = 150
select @i/100.0
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply