6> CREATE TABLE orders
7> (orderid INT NOT NULL,
8> price MONEY NOT NULL,
9> quantity INT NOT NULL,
10> orderdate DATETIME NOT NULL,
11> total AS price * quantity,
12> shippeddate AS DATEADD (DAY, 7, orderdate))
13> GO
1>
2> CREATE VIEW all_orders
3> AS SELECT orderid, price, quantity, orderdate, total, shippeddate
4> FROM orders
5> GO
1>
2> CREATE TRIGGER tr_orders ON all_orders INSTEAD OF INSERT
3> AS BEGIN
4> INSERT INTO orders SELECT orderid, price, quantity, orderdate FROM inserted
5> END
6> GO
1>
2> drop trigger tr_orders;
3> GO
1>
2> drop view all_orders;
3> GO
1>
2> drop table orders;
|