Randolph West wants to talk to us about how we use our MONEY
:
While
MONEY
andDECIMAL(19,4)
are functionally the same, they are stored differently on disk, and this is where it gets interesting. Let’s use a random amount of $ 4,513.19. Since it’s small enough to fit in bothMONEY
andSMALLMONEY
, we can do a simple experiment. When we ask SQL Server to store this value in aMONEY
data type, it will store it (byte-reversed) as0x7CA8B00200000000
. TheSMALLMONEY
version of this amount would look almost identical, stored as0x7CA8B002
(without the leading zeroes). A quick look at this byte-reversed value (0x02B0A87C
) in a hex calculator gives us the amount of 45,131,900. After moving the decimal point four places to the left, we get our starting value of 4513.1900.
But read on to see how that compares to other data types.