March 31, 2004 at 6:29 am
According to BOL, the default for MONEY is 2 decimal places. My installation is defaulting to 4 decimal places.
Question is simple - how do I manipulate the MONEY data type to only show 2 decimal places, commas and dollar sign, as in - $1,234.00?
My script was working - casting a string as DECIMAL (10,2) and inserting into a MONEY column in the target table, but something has changed and the script is no longer working - so I figure this is as good a time as any to 'master' the use of the money data type, and then I won't have any more INSERT errors.
Tia !
randy
March 31, 2004 at 1:34 pm
Not sure where you got Money as 2 Decimals, my BOL shows them as 4.
Convert(Char(20),money,?)
? = 1 -> commas and 2 decimals
? = 2 -> no commas and 4 decimals
Not much to choose from really.
No idea with SQL how to get the $, well okay, '$' + Ltrim(Convert(Char(20),money,1)) ...
But thats getting ugly, not to say I haven't written a lot worse SQL
KlK
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply