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 Development (2000)
 Data types for storing kilograms and grams

Author  Topic 

hasanali00
Posting Yak Master

207 Posts

Posted - 2005-10-05 : 08:29:39
I want a table field to store values in Kilograms

So when I enter "1", this would mean to me that this is 1 kilogram.

Similarly, I want to be able to enter values in grams. So if I want to enter 100 grams, I would have to enter 0.100

Which data type do I need for this type of column???

Currently, I am using Decimal (Percision=18, Scale=2)

But when I enter 0.100 (100 grams), it turns to 0.1
And when I enter 0.10 (10 grams), it again turns to 0.1

So any idea whats the best data type to use for this type of enteries.

regards

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-10-05 : 08:32:28
this is the correct type.
traling zeros are a front end format problem not db's.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-10-05 : 08:34:36
That is because 100 grams is 0.100 KG and 10 Grams is 0.010 KG

and I reckon you should use DECIMAL(18, 3) seeing as there are 1000 grams in a KG


Duane.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-05 : 09:16:05
>> reckon you should use DECIMAL(18, 3) seeing as there are 1000 grams in a KG

Yes

You should not worry about the data formation in SQL Server
0.1 is equivalent to 0.10 or 0.100 or 0.1000 etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

hasanali00
Posting Yak Master

207 Posts

Posted - 2005-10-05 : 09:33:52
quote:
Originally posted by ditch

That is because 100 grams is 0.100 KG and 10 Grams is 0.010 KG

and I reckon you should use DECIMAL(18, 3) seeing as there are 1000 grams in a KG


Duane.



Thanks for making me realise i was entering wrong data
Go to Top of Page
   

- Advertisement -