We're designing the data model for a project. The app will be in .NET, the
database will be in SQL Server 2005.
I'm a little confused on type conversion between the two and which I should
choose.
I found this good comparison chart: http://msdn2.microsoft.com/en-us/library/ms131092.aspx
But for monetary amounts, it looks like decimal is how .NET is going to
store the value. So then, should I go with decimal in the database for a
nice match? But then it looks like money would be a good choice.
How do I know which I should ideally choose?
It would be nice if all the types exactly matched up between the platforms.
Thanks,
Ron 4 3683
Please disregard this -thx
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
We're designing the data model for a project. The app will be in .NET,
the database will be in SQL Server 2005.
I'm a little confused on type conversion between the two and which I
should choose.
I found this good comparison chart: http://msdn2.microsoft.com/en-us/library/ms131092.aspx
But for monetary amounts, it looks like decimal is how .NET is going to
store the value. So then, should I go with decimal in the database for a
nice match? But then it looks like money would be a good choice.
How do I know which I should ideally choose?
It would be nice if all the types exactly matched up between the
platforms.
Thanks,
Ron
Ronald,
Why disregard? Care to say what conclusions you came to?
Personally, I think that if you are going to store money values in the
database, then money is fine. However, if the table you are storing values
on is an intermediate table which will store values performed on money and
then have more calculations performed on those results, then you should use
decimal with a much larger scale.
For example, say you have a Product table, with a Price field which is
the price for the Product. This price should be Money.
Now, if you had an intermediate table, with an average of how much money
was spent per customer, then that field should be decimal, with a larger
scale. The reason for this is that if you use those averages as inputs into
calculations later, then you don't want a truncation of values before the
money values go into the calc.
But then again, maybe you do, it all depends on what the accuracy you
need. Personally, I like to have as many places as possible being stored
(given practical limitations) and used for my intermediary calcs and then
perform the final rounding when the results are presented back to the user.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
Please disregard this -thx
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
>We're designing the data model for a project. The app will be in .NET, the database will be in SQL Server 2005.
I'm a little confused on type conversion between the two and which I should choose.
I found this good comparison chart: http://msdn2.microsoft.com/en-us/library/ms131092.aspx
But for monetary amounts, it looks like decimal is how .NET is going to store the value. So then, should I go with decimal in the database for a nice match? But then it looks like money would be a good choice.
How do I know which I should ideally choose?
It would be nice if all the types exactly matched up between the platforms.
Thanks, Ron
On Sat, 14 Apr 2007 10:20:31 -0400, Nicholas Paldino [.NET/C# MVP] wrote:
Ronald,
Why disregard? Care to say what conclusions you came to?
Personally, I think that if you are going to store money values in the
database, then money is fine. However, if the table you are storing values
on is an intermediate table which will store values performed on money and
then have more calculations performed on those results, then you should use
decimal with a much larger scale.
For example, say you have a Product table, with a Price field which is
the price for the Product. This price should be Money.
Now, if you had an intermediate table, with an average of how much money
was spent per customer, then that field should be decimal, with a larger
scale. The reason for this is that if you use those averages as inputs into
calculations later, then you don't want a truncation of values before the
money values go into the calc.
But then again, maybe you do, it all depends on what the accuracy you
need. Personally, I like to have as many places as possible being stored
(given practical limitations) and used for my intermediary calcs and then
perform the final rounding when the results are presented back to the user.
I agree with you about the accuracy but what benefits can you derive seeing
as money only makes sense to 2-3 decimal points?
--
Bits.Bytes http://bytes.thinkersroom.com
Rad,
If you are storing intermediate calculation values in a table which are
monetary values, then you might want that accuracy when using those
intermediary values in further calculations. It wouldn't be until the end
where you want to apply the rounding.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1c****************@thinkersroom.com...
On Sat, 14 Apr 2007 10:20:31 -0400, Nicholas Paldino [.NET/C# MVP] wrote:
>Ronald,
Why disregard? Care to say what conclusions you came to?
Personally, I think that if you are going to store money values in the database, then money is fine. However, if the table you are storing values on is an intermediate table which will store values performed on money and then have more calculations performed on those results, then you should use decimal with a much larger scale.
For example, say you have a Product table, with a Price field which is the price for the Product. This price should be Money.
Now, if you had an intermediate table, with an average of how much money was spent per customer, then that field should be decimal, with a larger scale. The reason for this is that if you use those averages as inputs into calculations later, then you don't want a truncation of values before the money values go into the calc.
But then again, maybe you do, it all depends on what the accuracy you need. Personally, I like to have as many places as possible being stored (given practical limitations) and used for my intermediary calcs and then perform the final rounding when the results are presented back to the user.
I agree with you about the accuracy but what benefits can you derive
seeing
as money only makes sense to 2-3 decimal points?
--
Bits.Bytes http://bytes.thinkersroom.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number....
|
by: James Foreman |
last post by:
I'm using DB2 UDB 8.1.2 on Suse linux. Try this:
CREATE TABLE testsums (cost_of_sale decimal(7,2), price decimal(9,
2));
INSERT INTO testsums VALUES (10000, 30000);
SELECT cost_of_sale/price...
|
by: BerkshireGuy |
last post by:
Our IT department wants to place our Access 2000 tables on an SQL
server due to the fact the tables are quite large.
With that said, can we still use the Access queries or do we have to do...
|
by: Brian P. Hammer |
last post by:
I have data from multiple SQL tables, some of the tables will only have one
row, while others multiple rows. I load a bunch of data from the various
tables and add them to a third party grid. With...
|
by: mesut demir |
last post by:
Hi All,
When I create fields (in files) I need assign a data type like char,
varchar, money etc.
I have some questions about the data types when you create fields in a
file.
What is the...
|
by: Sam |
last post by:
I am trying to use a Simple form with 3 fields from SQL NorthWind
Database (Order Details Table with 3 Fields. - OrderId, ProductId and
Unit Price). The Field Unit Price has a data type of 'Money...
|
by: Sam |
last post by:
Folks..
I am trying to use a Simple form with 3 fields from SQL NorthWind
Database (Order Details Table with 3 Fields. - OrderId, ProductId and
Unit Price). The Field Unit Price has a data...
|
by: Ronald S. Cook |
last post by:
For money values, C# seems to have just DOUBLE as a type.
SQL Server 2005 has data types DECIMAL, FLOAT, MONEY, and NUMERIC that seem
to all be able to hold a money time.
So, given I'll be...
|
by: Stephan Diehl |
last post by:
Hi lazyweb,
I'm wondering, if there is a usable money data type for python available.
A quick search in pypi and google didn't convey anything, even though the
decimal data type seemed to be...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |