I am working on a Database that uses the Float data type to store values that should only be 2 decimal positions (dollars and cents). 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 2 decmial positions. This database has hundreds of tables using Float and it would be helpful to be able to automatically ROUND the float columns.
Can this be done?
Can a TRIGGER be used on INSERT and UPDATE to do a ROUND on the Column?
If it can could you show how you would code the TRIGGER and would you recommend it?
Any other ideas?
We are using SQL Server 2005.
Here is a post that asks the question Use Float or Decimal for Accounting Application Dollar Amount? and I like the one responce that said
"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 world of hurt".
I feel the pain!