Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Posts
    42

    Unanswered: smallmoney data type

    whenever i add values in my price column, it automatically put 4 decimal places. how will i limit to 2 decimal places of this smallmoney datatype?

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    You use numeric instead Personally I never ever use the monetary datatypes.
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The MONEY and the SMALLMONEY datatypes are "hardwired" with four decimal places. In some monetary systems, this is silly because everything is stated in the smallest unit the system supports, so fractions are irrelevant. In other systems, four decimal places was barely enough.

    Think hard about how you want to use your monetary data. Using DECIMAL (6, 2) is great for some things and it nicely dodges the problems with "penny rounding" in the display, but it frequently encourages lazy programming practice that will have auditors shaking their heads in a year or two and refusing to issue fiduciary statements... This can be funny, unless it interferes with the ability to value/sell your business, or when the guy on the other side of the desk works for the IRS.

    Just be carefull, the answer that is easy now isn't always good later!

    -PatP

  4. #4
    Join Date
    Feb 2007
    Posts
    42
    i think decimal(6,2) is enough for my values because they don't have fractions. just .00! what do you think?

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    While DECIMAL(6, 2) might be good enough for a simple school assignment, I would probably never accept it for a production system. It is definitely easy to use, but it would lead you to make all kinds of silly programming mistakes that would cost a fortune to find and fix.

    -PatP

Posting Permissions

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