Mega Code Archive

 
Categories / MSSQL Tutorial / Table
 

Computed columns are (by default) virtual columns not physically stored in the table

Their values are recalculated each time they are referenced in a query. CREATE TABLE orders         (orderid INT NOT NULL,         price MONEY NOT NULL,         quantity INT NOT NULL,         orderdate DATETIME NOT NULL,         total AS price * quantity PERSISTED,         shippeddate AS DATEADD (DAY, 7, orderdate)) GO drop table orders; GO