VistaDB 5
Gibraltar VistaDB > How does VistaDB work? > Physical Database File Storage > Data Types and Mapping from SQL Server to VistaDB
Data Types and Mapping from SQL Server to VistaDB
VistaDB 5 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 -
VarBinary (Max) Image Image - Image Byte[]
Int Int Int Int Int Int32
Money Money Money Money Money Decimal
NChar NChar NChar NChar NChar String
NVarchar (Max) NText NText NText (500Mb) NText String
NVarchar NVarchar NVarchar NVarchar NVarchar String
Real Real Real Real Real Single
SmallDateTime SmallDateTime SmallDateTime - SmallDateTime Int16
SmallInt SmallInt SmallInt SmallInt SmallInt Int16
SmallMoney SmallMoney SmallMoney - SmallMoney Decimal
Varchar (Max) 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 - -
DateTime2 - DateTime2   - DateTime2
Date - Date   - DateTime
Time - Time   - Timespan
DateTimeOffset - DateTimeOffset   - DateTimeOffset
TImespan - Timespan   - Timespan
- - Geography - - (class)
- - Geometry - - (class)


Decimal data types 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


VistaDB uses .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 Stack Overflow 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).

Remarks

Each data type also supports NULL.

See Also