understanding MONEY() datatype with precision and scale

Viewed 8553

I was going through some sample exam questions on this link:

http://www.elearningexams.com/70-461-notes/page/2

and came across question no.1 below.

Which of the following datatypes has a fixed precision and a scale of six digits?

A. Double

B. Money

C. Int

D. Numeric

E. SmallInt

F. VarInt

G. Float

Answer is B. Money

I didn't understand how Money() can have a fixed precision and a scale of six digits. I went through this MSDN doc but didn't understand: https://docs.microsoft.com/en-us/sql/t-sql/data-types/money-and-smallmoney-transact-sql

Can someone please explain with some examples and how precision and scale is measured in MONEY(). Thanks.

2 Answers

Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number.

Therefore:

MONEY has a precision of 19 and a scale of 4

SMALLMONEY has a precision of 10 and a scale of 4

The precision and scale of the numeric data types besides decimal are fixed. The scale of MONEY data type is 4 (four decimal digits) More on precision and scale here

In TSQL smallmoney has scale of 4 and fixed precision of 10

smallmoney: -214748.3648 to 214748.3647

Money has a scale of 4 and fixed precision of 19

money: -922337203685477.5808 to 922337203685477.5807

I therefore conclude that the answer is wrong (perhaps they meant smallmoney to be option B)

Related