One table with two after-delete triggers : Trigger for after « Trigger « SQL Server / T-SQL Tutorial






3> CREATE TABLE test_trigger
4> (col1 int,
5>  col2 char(6) )
6> GO
1> INSERT INTO test_trigger VALUES (1, 'First')
2> INSERT INTO test_trigger VALUES (2, 'Second')
3> INSERT INTO test_trigger VALUES (3, 'Third')
4> INSERT INTO test_trigger VALUES (4, 'Fourth')
5> INSERT INTO test_trigger VALUES (5, 'Fifth')
6> GO
1>
2> CREATE TRIGGER delete_test
3> ON test_trigger AFTER DELETE
4> AS
5> PRINT 'You just deleted a row!'
6> GO
1>
2> ALTER TRIGGER delete_test
3> ON test_trigger AFTER DELETE
4> AS
5> IF @@ROWCOUNT = 0 RETURN
6> PRINT 'You just deleted a row!'
7> GO
1>
2> DELETE test_trigger
3> WHERE col1 = 0
4> GO
1>
2> drop table test_trigger;
3> GO
1>








22.3.Trigger for after
22.3.1.One table with two after-delete triggers
22.3.2.An after-update trigger
22.3.3.Rolling Back in an AFTER Trigger
22.3.4.Using an AFTER Trigger to Remove Time from a datetime Column