insert trigger
-
Hi, I have code that fires a stored procedure, to insert a new location. I now need to add another insert, that inserts a destination into another table, using a trigger. I pass the following variable to my location table : @LocationCode I want to create a trigger, that everytime an INSERT is fired on the Location table, it should add a row to my Destination table. Here is what I have to create the trigger:
CREATE TRIGGER DestInsert ON [Location] FOR INSERT AS INSERT INTO Destination (LocationCode, Destination, AreaCode, DeletedFlag) VALUES (@LocationCode, 'New', '123C', 0)
Will this create a trigger for me, that adds the same @LocationCode variable I added for the stored Procedure to the trigger? -
Hi, I have code that fires a stored procedure, to insert a new location. I now need to add another insert, that inserts a destination into another table, using a trigger. I pass the following variable to my location table : @LocationCode I want to create a trigger, that everytime an INSERT is fired on the Location table, it should add a row to my Destination table. Here is what I have to create the trigger:
CREATE TRIGGER DestInsert ON [Location] FOR INSERT AS INSERT INTO Destination (LocationCode, Destination, AreaCode, DeletedFlag) VALUES (@LocationCode, 'New', '123C', 0)
Will this create a trigger for me, that adds the same @LocationCode variable I added for the stored Procedure to the trigger?use.. Inserted.Locationcode it will fetch the location code from inserted location enjoy :)
Dinesh Sharma
-
use.. Inserted.Locationcode it will fetch the location code from inserted location enjoy :)
Dinesh Sharma
-
DineshSharma wrote:
Inserted.Locationcode
Thanks, just one more thing. Is Inserted a DB function, or does it gets the last LocationCode inserted?
It's a table that contains all the rows that were inserted when the trigger was fired.