Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    82

    Unanswered: Varchar to Decimal rounding issues

    hi all

    I have a problem with SQL rounding my decimals up when I pull them from a temp table that has the column set as VARCHAR. What is happening is I am pulling the info from a flat file but each column has "" around each field so I must make the temp table columns all VARCHAR so I may pull the info from the file properly. So after the info has been extracted, I run an update statement on the temp table to remove all quotes. Once this is done, the revised info is inserted into a staging table and any field that is a represented as a decimal is labled as such in the staging table.

    What I am running into is when the info is inserted into the staging table, the decimals are rounded up to whole values. The column has been checked to verify that it is indeed a decimal. I even have a CAST statement in the insert hoping to combat the rounding issue, but it is not helping.

    So what reason(s) would my decimals be rounding up?

    Thanks alot

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Decimal what? Decimal(10,4)? Decimal(10,0)? What is the precision of the datatype you have defined?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Mar 2006
    Posts
    82
    Quote Originally Posted by blindman
    Decimal what? Decimal(10,4)? Decimal(10,0)? What is the precision of the datatype you have defined?
    Sorry....Dec(10,5)

    Ive tried several different precisions...all the same issue

  4. #4
    Join Date
    Mar 2006
    Posts
    82
    Silly mistake.....The table definition in the staging table had the precision/scale at (18,0). I guess that is the default when you create a table through enterprise manage though I have never ran into this before when creating tables this way. Sorry for the stupidity.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •