|
VistaDB 4
|
SQL Server 2005
|
SQL Server 2008
|
SQL CE 3.5
|
VistaDB 3
|
.NET System
|
|
BigInt
|
BigInt
|
BigInt
|
BigInt
|
BigInt
|
Int64
|
|
Bit
|
Bit
|
Bit
|
Bit
|
Bit
|
Byte
|
|
Char
|
Char
|
Char
|
-
|
Char
|
String
|
|
DateTime
|
DateTime
|
DateTime
|
DateTime
|
DateTime
|
DateTime
|
|
Decimal*
|
Decimal
|
Decimal
|
Decimal*
|
Decimal*
|
Decimal*
|
|
Float
|
Float
|
Float
|
Float
|
Float
|
Double
|
|
Identity Fields
|
Identity Fields
|
Identity Fields
|
Identity Fields
|
Identity Fields
|
-
|
|
Image
|
Image
|
Image
|
-
|
Image
|
Byte[]
|
|
Int
|
Int
|
Int
|
Int
|
Int
|
Int32
|
|
Money
|
Money
|
Money
|
Money
|
Money
|
Decimal
|
|
NChar
|
NChar
|
NChar
|
NChar
|
NChar
|
String
|
|
NText
|
NText
|
NText
|
NText (500Mb)
|
NText
|
String
|
|
NVarchar
|
NVarchar
|
NVarchar
|
NVarchar
|
NVarchar
|
String
|
|
Real
|
Real
|
Real
|
Real
|
Real
|
String
|
|
SmallDateTime
|
SmallDateTime
|
SmallDateTime
|
-
|
SmallDateTime
|
Int16
|
|
SmallInt
|
SmallInt
|
SmallInt
|
SmallInt
|
SmallInt
|
Int16
|
|
SmallMoney
|
SmallMoney
|
SmallMoney
|
-
|
SmallMoney
|
Decimal
|
|
Text
|
Text
|
Text
|
-
|
Text
|
String
|
|
Timestamp
|
Timestamp
|
Timestamp
|
Timestamp
|
Timestamp
|
Int64
|
|
TinyInt
|
TinyInt
|
TinyInt
|
TinyInt
|
TinyInt
|
Byte
|
|
UniqueIdentifier
|
UniqueIdentifier
|
UniqueIdentifier
|
UniqueIdentifier
|
UniqueIdentifier
|
Guid
|
|
VarBinary
|
VarBinary
|
VarBinary
|
VarBinary(4000)
|
VarBinary
|
Byte[]
|
|
VarChar
|
VarChar
|
VarChar
|
-
|
VarChar
|
String
|
|
-
|
XML
|
XML
|
-
|
-
|
-
|
|
-
|
-
|
RowVersion
|
RowVersion
|
-
|
-
|
|
(4.1)
|
-
|
DateTime2
|
|
-
|
DateTime2
|
|
(4.1)
|
-
|
Date
|
|
-
|
DateTime
|
|
(4.1)
|
-
|
Time
|
|
-
|
DateTime
|
|
(4.1)
|
-
|
DateTimeOffset
|
|
-
|
DateTimeOffset
|
|
(4.1)
|
-
|
Timespan
|
|
-
|
Timespan
|
|
-
|
-
|
Geography
|
-
|
-
|
(class)
|
|
-
|
-
|
Geometry
|
-
|
-
|
(class)
|
Decimal datatypes are different in .Net than SQL Server
.Net decimals do not store and cannot cover the same range as the SqlDecimal type.
( See this article at MSDN )
"SqlDecimal has different underlying data structures from its corresponding .NET
Framework Decimal data type. Decimal has no concept of precision." - MSDN
We use .Net managed decimals for storage. Precision is not actually enforced in
.Net other than at creation time. .Net truncates the values and stores them in a
decimal. There is no way to preserve those values in a .Net operation (if you do
any operation to a decimal in .Net it is rounded and presented as a system decimal
afterwards).
One alternative is to store the values as strings, and parse back the string to
get the effectivescale and effectiveprecision on a per value stored basis. See this
stackoverflow post for other people talking about the issue as well (StackOverflow question on Precision and Scale).
Another option if you need that level of scale and precision is to store the levels
you need in multiple columns and then recalculate actual decimal values (keeping
in mind that .Net will round them on you with your next operation).