Mega Code Archive

 
Categories / MSSQL Tutorial / Table
 

Create a computed column

3> 4> SET QUOTED_IDENTIFIER ON 5> GO 1> 2> 3> CREATE TABLE employee 4> (ID int NOT NULL, 5> total int NOT NULL, 6> count int NOT NULL, 7> AvgSharesPerShareholder AS (total/count) PERSISTED); 8> 9> select * from employee; 10> GO ID          total       count       AvgSharesPerShareholder ----------- ----------- ----------- ----------------------- (0 rows affected) 1> 2> drop table employee; 3> GO 1> 2> SET QUOTED_IDENTIFIER OFF 3> GO 1>