Computed Column In SQL Server

In this article, we will see what ‘Computed Column in SQL Server' is, and how we can use it.
Computed Column In SQL Server

First of all, what is a Computed column in SQL Server?

Computed column as the name gives an idea it's related to something calculation/ computation, yes, computed columns are similar to a column in Excel with an applied formula that calculates the value automatically of the given query or the columns.
Computed columns are columns with some user-defined expression or with some formula to calculate the corresponding columns with operators or with some query.
Let's take an example,
Creating a table named 'CalculationTable' with a computed column named 'Age',
  1. Create table CalculationTable  
  2. (  
  4.    NAME NVARCHAR(50) null,  
  5.    DATEOFBIRTH DATE null,  
  7. )  
You can also use the SSMS user interface to define that column (formula), let’s see how,
Computed Column In SQL Server 
Now let's insert some data into the table,
Computed Column In SQL Server 
In the above example, AGE is computed column, whenever we insert the value of DATEOFBIRTH then AGE will be calculated automatically.
I hope this will be helpful to understand the Computed Columns in SQL Server.
For practice, you can download the attached scripts.