What data type to use for representing currency in C# and Sql Server 2005/2008?

What data type to use for representing currency in C# and Sql Server 2005/2008?

This post will be short and sweet.  What data type should you use to represent currencies in C#? – Decimal

If you use double, you will end up with rounding errors on more precise numbers, and if you are writing applications that support multiple currencies, namely currencies that use very large numbers, such as the Indonesia Rupiah ($1 = 9,345.8 Indonesian Rupiahs) you will also get doubles represented in scientific notation when they reach very large values (think trillions).

In C# use Decimal

Now for SQL Server 2005/2008 I believe the best practice would be to use the money datatype if you are dealing exclusively with U.S. dollars, otherwise you should use decimal to get more precise values.

There are 2 comments .

Delorse Pooni

Hey there, I think you most likely are able to help me. I have a MSSQL .ldf and .mdf file which I have to restore. Any opinions on how to do this? Regards

Reply »

    You should be able to attach an MDF file Delorse. Have you tried Googling this? There should be plenty of detailed instructions out there. Good luck!

    Reply »

Share Your Thoughts!


What My Clients Say

Karin - Hope and Future

Brent has always been very prompt and generally exceeds our expectations with his work. His maintenance fee is very reasonable. I strongly recommend him!  We get many compliments on our beautiful web site!


I contacted Krueger Web Design and Brent did everything.  He setup a test site with the changes so we could verify everything was correct before we transferred from my old hosting provider.  During the setup and conversion Brent was extremely professional and responsive. He responded to any issues the same day.

Dan Kaufman
Emily - GFCLT

We've had a great experience working with Krueger Web Design. Prompt responses, great ideas, effective work... all at a reasonable price! This was the perfect fit for our organization.

Mahmud - ACMC

I would love to recommend you to anyone! You have been very helpful when we needed you the most.

Brian - SEMNIC

Working with Krueger Web Design was effortless. Communicating what I wanted for the website and the results that I saw were identical. The customer service was always prompt and I am completely satisfied with the product.

Zach - Stadium Club

Exactly what I wanted! Fast turnaround time and very affordable. Answered all of our questions quickly and made adjustments promptly. Very easy to work with and puts everything into terminology that even I can understand!

Contact Krueger Web Design

Have a question for me? Need an estimate on some work? You can email me at brent@kruegerwebdesign.com or drop me a line using the button below:

Copyright © 2018 Krueger Web Design - All rights reserved
Web Design in Madison, WI