Create a computed column and round

后端 未结 1 1061
天涯浪人
天涯浪人 2021-01-20 18:29

I have 3 numeric(18,2) columns in my table. I want to create a fourth column that is computed. I created the computed column in SSMS

相关标签:
1条回答
  • 2021-01-20 19:25

    You need to convert the computed column to numeric(18,2)

    Example :

    CREATE TABLE computed
      (
         a NUMERIC(18, 2),
         b NUMERIC(18, 2),
         c AS CONVERT(NUMERIC(18, 2), a * b)
      )
    
    INSERT INTO computed VALUES (1,2)
    
    SELECT *
    FROM   computed 
    
    0 讨论(0)
提交回复
热议问题