title: How to round a column defined as float on INSERT and UPDATE in SQL Server 2005
body: <p>I am working on a database that uses the <em>float</em> data type to store values that should only be two decimal positions (dollars and cents).</p>
  <p>Using float appears to work OK, as long as the person updating the float column does a ROUND. Of course, this does not always happen and then when a SUM is done it is always off a few pennies from what is displayed because the display is formatted to show only two decimal positions. This database has hundreds of tables using float and it would be helpful to be able to automatically ROUND the float columns.</p>
  <p>Can this be done?</p>
  <p>Can a TRIGGER be used on INSERT and UPDATE to do a ROUND on the Column?</p>
  <p>If it can, could you show how you would code the TRIGGER and would you recommend it?</p>
  <p>Any other ideas?</p>
  <p>We are using <a href="https://en.wikipedia.org/wiki/History_of_Microsoft_SQL_Server#SQL_Server_2005" rel="nofollow noreferrer">SQL Server 2005</a>.</p>
  <p>Here is a post that asks the question, <em><a href="https://stackoverflow.com/questions/61872/use-float-or-decimal-for-accounting-application-dollar-amount">Use Float or Decimal for Accounting Application Dollar Amount?</a></em>, and I like the one response that said</p>
  <blockquote>
  <p>&quot;You should really consider using some type of fixed point / arbitrary-precision number package (e.g., Java BigNum, python decimal module) otherwise you'll be in for a <strong>world of hurt</strong>&quot;.</p>
  </blockquote>