Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL decimal equivalent in .NET

What is the SQL (MS SQL Server) Decimal equivalent in .NET?

Should it be Double, Decimal or Float (Single in VB.NET)?

like image 343
serhio Avatar asked Oct 06 '11 12:10

serhio


2 Answers

There's no exact equivalent type in .NET, as SQL's decimal type is fixed point, whereas .NET's System.Decimal type is a floating (decimal) point type.

However, System.Decimal is definitely the closest match, and should generally be what's used to represent the value stored in a decimal column in a SQL database.

like image 67
Jon Skeet Avatar answered Sep 27 '22 23:09

Jon Skeet


Use Decimal, as can be seen in this table.

like image 38
Oded Avatar answered Sep 27 '22 23:09

Oded