How does SQL Server store decimal type values internally?

前端 未结 1 1497
有刺的猬
有刺的猬 2021-01-06 08:38

In SQL Server you can use FLOAT or REAL to store floating point values the storage format of which is cleared defined by the IEEE 754 standard. For

相关标签:
1条回答
  • 2021-01-06 08:55

    Martin's Smith comment gives you the clue. SQL Server does not use BCD. It stores the data as a whole number, without the decimal place (which it can do because the decimal place is stored in the metadata for the column). So 5.7456 is stored as 57456, or 0xE070. After SQL's infamous byte swapping this is transformed to 70 E0 00 00.

    The leading 01 is the sign. 01 is used for positive numbers; 00 for negatives.

    (However, I must ask - why do you need this? In typical use, you should never need to bother with SQL Server's internals)

    0 讨论(0)
提交回复
热议问题