Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Two digits after decimal point

Author  Topic 

CanadaDBA

583 Posts

Posted - 2005-04-15 : 12:22:12
"Money" data type provides 4 digits after decimal point. I need 10 digits for integer part and only two digits as fractional part.

Canada DBA

CanadaDBA

583 Posts

Posted - 2005-04-15 : 12:44:15
Found it: Decimal(12,2)

DECLARE @M Decimal(12,2)

SET @M = 1234567890.09

SELECT @M


Canada DBA
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-04-15 : 19:58:49
FWIW - Every accounting package that I've worked with carries money values to at least three decimal places.

HTH

=================================================================
Every act of conscious learning requires the willingness to suffer an injury to one's self-esteem. That is why young children, before they are aware of their own self-importance, learn so easily; and why older persons, especially if vain or important, cannot learn at all. -Thomas Szasz, author, professor of psychiatry (1920- )
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-04-15 : 20:33:09
If you only need to DISPLAY 2 decimal places, but not actually round off the value, then do it in your application/presentation layer, or use the CONVERT() or STR() SQL functions to convert it to a string/varchar.

You are better off using money/smallmoney rather than decimal if you're storing monetary values. As Bustaz said, you get more accuracy with money, and it's more efficiently stored and calculated than decimal types.
Go to Top of Page

CanadaDBA

583 Posts

Posted - 2005-04-20 : 14:35:05
Thanks for posts; The request was for two digit after decimal point and only in table level.

Thanks,

Canada DBA
Go to Top of Page
   

- Advertisement -