Reputation: 13551
I have to represent numbers in my database, which are amounts of chemical substances in food, like fats, energy, magnesium and others. These values are decimals in format 12345.67.
If I use decimal (5,2)
as data type in SQL Server, it maps to Decimal
type in Entity Framework. If I use float as data type in SQL Server, it maps to Double
in Entity Framework.
I'm not sure what the best data type in SQL Server would have to be, or doesn't it really matter a lot?
EDIT - in my case it should be decimal(7,2)
, as mentioned in some of the remarks!
Thanks.
Upvotes: 5
Views: 5738
Reputation: 4519
DECIMAL(7,2)
would be better than float - it's exactly what you need (5 + 2 digits). With floating types (eg. float, double) you may have some problems - e.g. with rounding.
Upvotes: 4
Reputation: 432657
You need decimal(7,2)
Differences:
References:
Upvotes: 11