I have created an AFTERINSERT trigger & INSTEADOFINSERT trigger on tables.
Code:create trigger trig_AFTERINSERT on original FOR INSERT AS BEGIN INSERT trigger_original(Roll,UserName,Password) SELECT ROLL,Name,Name+'124' FROM INSERTED ENDWHen I execute the above statemnet, 2 Rows get inserted. ONE ROW IS INSERTED in TABLE - original, ANOTHER ROW GET INSERTED IN TABLE - trigger_original.Code:insert into original values(1,'A')
NOW I HAVE CREATED an INSTEADOFINSERT Trigger on the same tables.
Code:create trigger trig_INSTEADOFINSERT on original INSTEAD OF INSERT AS INSERT trigger_original(Roll,UserName,Password) SELECT ROLL,Name,Name+'124' FROM INSERTEDWHen the above insert statement is executed, I get message 2 Rows Affected.Code:insert into original values(2,'B')
But when i select the records
- IT CONTAINS ONLY THE ONE ROW ( WITH ROLL NO 1)Code:Select * from original
( TWO ROWS ARE THERE - CORRECT)Code:Select * from trigger_original
WHy the row is not inserted into table original that is inserted using the INSTEADOF_INSERT Trigger.


Reply With Quote
