4>
5> CREATE TABLE MyTable
6> (
7> ID int NOT NULL PRIMARY KEY,
8> del char (1) NOT NULL DEFAULT 'N'
9> )
10> GO
1>
2> --INSTEAD OF Trigger for Logical Deletes
3> CREATE TRIGGER trd_MyTable ON MyTable INSTEAD OF DELETE
4> AS
5> IF @@ROWCOUNT = 0
6> RETURN
7> UPDATE M
8> SET
9> del = 'Y'
10> FROM
11> MyTable AS M
12> JOIN
13> deleted AS D ON D.ID = M.ID
14> GO
1>
2> drop table mytable
3> GO
|