Difference between numeric, float and decimal in SQL Server

后端 未结 8 1433
半阙折子戏
半阙折子戏 2020-11-22 04:27

What are the differences between numeric, float and decimal datatypes and which should be used in which situations?

For any ki

8条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 05:18

    They Differ in Data Type Precedence

    Decimal and Numeric are the same functionally but there is still data type precedence, which can be crucial in some cases.

    SELECT SQL_VARIANT_PROPERTY(CAST(1 AS NUMERIC) + CAST(1 AS DECIMAL),'basetype')
    

    The resulting data type is numeric because it takes data type precedence.

    Exhaustive list of data types by precedence:

    Reference link

提交回复
热议问题