Tuesday, July 12, 2016

Computed Columns in a Table


How to create computed "Age" column


  • Create the table like this.

  • Enter the column name and accept the default data type (nchar(10)). The Database Engine determines the data type of the computed column by applying the rules of data type precedence to the expressions specified in the formula.
  • In the Column Properties tab, expand the Computed Column Specification property.
  • In the (Formula) child property, enter the expression for this column in the grid cell to the right. [code] (0 + Convert(Char(8),GETDATE(),112) - Convert(Char(8),DOB,112)) / 10000.
  • [/code]

No comments:

Post a Comment