VistaDB 6
VistaDB / How does VistaDB work? / Physical Database File Storage / Data Types and Mapping from SQL Server to VistaDB
In This Topic
    Data Types and Mapping from SQL Server to VistaDB
    In This Topic
    VistaDB SQL Server SQL CE .NET System
    BigInt BigInt BigInt Int64
    Bit Bit Bit Byte
    Char Char - String
    DateTime DateTime DateTime DateTime
    Decimal* Decimal Decimal* Decimal*
    Float Float Float Double
    Identity Fields Identity Fields Identity Fields -
    VarBinary (Max) Image - Byte[]
    Int Int Int Int32
    Money Money Money Decimal
    NChar NChar NChar String
    NVarchar (Max) NText NText (500Mb) String
    NVarchar NVarchar NVarchar String
    Real Real Real Single
    SmallDateTime SmallDateTime - Int16
    SmallInt SmallInt SmallInt Int16
    SmallMoney SmallMoney - Decimal
    Varchar (Max) Text - String
    Timestamp Timestamp Timestamp Int64
    TinyInt TinyInt TinyInt Byte
    UniqueIdentifier UniqueIdentifier UniqueIdentifier Guid
    VarBinary VarBinary VarBinary(4000) Byte[]
    VarChar VarChar - String
    - 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 the same resolution and can't cover the same range as the SqlDecimal type.

    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).

    See Also