sql-serversql-server-2008ssmsssms-2014management-studio-express

SQL Server 2014 Computed Column Specification Calculated Field Formula Error


Using the below column names in the formula field of computed column specification category (using Management Studio).

[[App_1]+[App_2]+[App_3]+[App_4]]

I'm getting this error:

'MyDatabase' table
Error validating the formula for column 'Total'.

App_1, App_2, App_3, App_4 all are numeric values.

Anyone knows how to handle this?


Solution

  • You have to get rid of the enclosing square brackets ('[', ']'), use:

    [App_1]+[App_2]+[App_3]+[App_4]
    

    Alternatively you can try with an SQL script:

    ALTER TABLE [dbo].[mytable] ADD [new_col] AS ([App_1]+[App_2]+[App_3]+[App_4])