Gene Wirchenko
2012-10-11 02:47:53 UTC
Dear SQLers:
According to Microsoft
http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx
money has four decimal digits. Unfortunately, if I use print to check
things, I sometimes do not get the four digits displayed as in:
print 12.345; -- prints 12.345
print convert(money,12.345); -- prints 12.35
print 12.35-convert(money,12.345); -- prints 0.0050
print convert(money,12.35)-convert(money,12.345); -- prints 0.01
print 12.345+convert(money,12.345)-12.345; -- prints 12.3450
The precision is apparently there per the third statement, but
how do I force it? I have tried variations with the second statement,
but I have been unable to get it to output 12.345. How is it that the
third statement gives four decimal digits, but the second and fourth
do not? The fifth statement is just plain weird.
I have no trouble with selects.
What am I missing, please?
Sincerely,
Gene Wirchenko
According to Microsoft
http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx
money has four decimal digits. Unfortunately, if I use print to check
things, I sometimes do not get the four digits displayed as in:
print 12.345; -- prints 12.345
print convert(money,12.345); -- prints 12.35
print 12.35-convert(money,12.345); -- prints 0.0050
print convert(money,12.35)-convert(money,12.345); -- prints 0.01
print 12.345+convert(money,12.345)-12.345; -- prints 12.3450
The precision is apparently there per the third statement, but
how do I force it? I have tried variations with the second statement,
but I have been unable to get it to output 12.345. How is it that the
third statement gives four decimal digits, but the second and fourth
do not? The fifth statement is just plain weird.
I have no trouble with selects.
What am I missing, please?
Sincerely,
Gene Wirchenko