Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with format of decimals between 0 and 1

Status
Not open for further replies.

chazbadd

Programmer
Sep 16, 2002
3
GB
Hello All,

I'm having problems with the output of queries that return the values from a decimal column in one of my tables. The values return as desired unless they are between 1 and 0. In this case the zero is truncated from before the decimal point. E.g

Value Returned as
1.56 1.56
7 7.00
0.98 .98
0 .00


The column is of type decimal with a scale of 2 and precision of 7 and length of 5. I have tried altering both these values and changing the column type to numeric, but still receive the same output.

The values are not stored like this either. Looking at the values in the database shows them to be 0.98, 0 etc etc. It is only when I run the query that the ouput alters to that above.

I'm running MS SQL Server 7

Regards

Charlie
 
Numbers do not show leading zeros. If you had 100, 10, 1, .1, and .01 all populating a N(5,2) field they'd appear as:
100.00
10.00
1.00
.10
.01

NOT

100.00
010.00
001.00
000.10
000.01

It does not affect the actual value, only the appearance of the value. These values can be re-formated in their output via convert or cast, but the SQL grid will still show them as numbers and therefor not include leading zeros. If you have to have them in a grid with leading zeros, you may need to store the converted/cast value to the grid as a character column.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top