Converting String To Decimal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benchpolo
    New Member
    • Sep 2007
    • 142

    Converting String To Decimal

    I have a column SUBAMOUNT where the value is converted to text 0000008917'. When the file is received I need to convert it to decimal (0000008917 converted to 89.17. I tried to use the CAST TSQL command, but it is giving me a result of 8917.00, which is incorrect.

    Thanks in advance for your assistance.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    convert(decimal (18,2),SUBAMOUN T)/100.0

    Comment

    • benchpolo
      New Member
      • Sep 2007
      • 142

      #3
      I'm getting an arithmetic overflow once I insert it to sql where the column data type is decimal (8,2).
      Please advise.

      Comment

      • gpl
        New Member
        • Jul 2007
        • 152

        #4
        Code:
        convert(decimal(8,2),SUBAMOUNT)/100.0

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32636

          #5
          Let's not waste time here.

          Why don't you post the code you already use, that returns a value of 8917, then we can see how safely, in those particular circumstances, this value can be divided by 100.

          Comment

          Working...