Is there any difference between DECIMAL and NUMERIC in SQL Server?

后端 未结 6 843
温柔的废话
温柔的废话 2020-11-28 06:13

Is there any difference between DECIMAL and NUMERIC data types in SQL Server?

When should I use DECIMAL and when NUMERIC?

6条回答
  •  情歌与酒
    2020-11-28 06:39

    They are synonyms, no difference at all.Decimal and Numeric data types are numeric data types with fixed precision and scale.

    -- Initialize a variable, give it a data type and an initial value
    
    declare @myvar as decimal(18,8) or numeric(18,8)----- 9 bytes needed
    
    -- Increse that the vaue by 1
    
    set @myvar = 123456.7
    
    --Retrieve that value
    
    select @myvar as myVariable
    

提交回复
热议问题