Convert decimal and numeric data

data-types
#tsql#data-types

10-19

9

20-28

13

29-38

17

For

and

data types, SQL Server considers each combination of precision and

scale as a different data type. For example,

and

are considered

different data types.

In Transact-SQL statements, a constant with a decimal point is automatically converted into a

data value, using the minimum precision and scale necessary. For example, the

constant

is converted into a

value, with a precision of

, and a scale of.

and

or

Possible loss of

precision

,

,

,

,

,

, or

and

Possible overflow

By default, SQL Server uses rounding when converting a number to a

or

value

with a lower precision and scale. Conversely, if the

option is

, SQL Server

raises an error when overflow occurs. Loss of only precision and scale isn’t sufficient to raise an

error.

Before SQL Server 2016 (13.x), conversion of

values to

or

is restricted to

values of precision 17 digits only. Any

value less than

(when set using either the

scientific notation of

or the decimal notation of

) rounds down to. This restriction doesn’t appear in SQL Server 2016 (13.x) and later versions.

Note

Informatica (connected through the SQL Server PDW Informatica Connector) only

supports 16 significant digits, regardless of the precision and scale specified.

Expand table

12.345
5
3
SET ARITHABORT

ON

5E-18
5E-18
0.000000000000000005
0