question

lokesh.shukla avatar image
lokesh.shukla asked

Trigger inside another trigger

--There are 3 tables: TableA, TableB and TableC. CREATE TABLE TableA (Id INT, Value VARCHAR(50)); CREATE TABLE TableB (Id INT, Value VARCHAR(50)); CREATE TABLE TableC (Id INT, Value VARCHAR(50)); --All tables are having triggers: TableA with trigger TriggerTableA, TableB with trigger TriggerTableB, and TableC with trigger TriggerTableC. CASE 1: UPDATE TABLE TableA SET Value='Updateing' WHERE Id=2 CREATE TRIGGER TriggerTableA ON TableA AFTER UPDATE AS UPDATE TableA SET Value='Updated TableA' WHERE Id= Inserted.Id CASE 2: UPDATE TABLE TableA SET Value='Updateing' WHERE Id=2 CREATE TRIGGER TriggerTableA ON TableA AFTER UPDATE AS UPDATE TableB SET Value='Updated TableB' WHERE Id= Inserted.Id CREATE TRIGGER TriggerTableB ON TableB AFTER UPDATE AS UPDATE TableB SET Value='Updated' WHERE Id= Inserted.Id CASE 3: UPDATE TABLE TableA SET Value='Updateing' WHERE Id=2 CREATE TRIGGER TriggerTableA ON TableA AFTER UPDATE AS UPDATE TableB SET Value='Updated TableB' WHERE Id= Inserted.Id CREATE TRIGGER TriggerTableB ON TableB AFTER UPDATE AS UPDATE TableC SET Value='Updated TableC' WHERE Id= Inserted.Id CREATE TRIGGER TriggerTableC ON TableC AFTER UPDATE AS UPDATE TableC SET Value='Updated' WHERE Id= Inserted.Id --I know the output of all the cases, but don't know how it is happening. Please explain it.
triggerhomework
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tom Staab avatar image Tom Staab ♦ commented ·
Can you please clarify? What is it that you don't understand? Is this a test question?
2 Likes 2 ·

1 Answer

·
Wilfred van Dijk avatar image
Wilfred van Dijk answered
seems you don't know what triggers do. have a look at: http://www.sqlteam.com/article/an-introduction-to-triggers-part-i
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.