Converting to Decimal

  • 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

  • I give up to easily sometimes...

    Using CAST(myval AS DECIMAL)/100 is giving me what I need.

    Thanks

  • You could just devide by 100.0:

    declare @i int

    set @i = 150

    select @i/100.0

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply