I am writing a trigger. Whenever I insert multiple values into my table, NFL.Widereceivers, I want it to automatically insert these values into another table, AFC.North. I have written a trigger, and it works to an extent:
begin
declare
@name varchar(30),
@team varchar(3),
@receptions int,
@yards int,
@touchdowns int
select @name = Name from inserted
select @team = Team from inserted
select @receptions = Receptions from inserted
select @yards = Yards from inserted
select @touchdowns = Touchdowns from inserted
if (@team = 'PIT' or @team = 'BAL' or @team = 'CIN' or @team = 'CLE')
begin
insert into AFC.North (Name, Team, Receptions, Yards, Touchdowns)
values (@name, @team, @receptions, @yards, @touchdowns);
end
end
However, this trigger does not work if I insert multiple values into NFL.Widereceivers, only the first row is inserted into AFC.North.
How can I make the trigger insert multiple rows of data?