SQL Server/T-SQL Tutorial/Table/Computed Columns — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 16:46, 26 мая 2010

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

   <source lang="sql">

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</source>