我在寫觸發器。每當我向我的表中插入多個值,NFL.Widereceivers,我希望它自動將這些值插入到另一個表,AFC.North。我寫了一個觸發器,它工作在一定程度上:用觸發器插入
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
但是,如果我插入多個值到NFL.Widereceivers,只有第一個行插入到AFC.North這觸發不起作用。
如何讓觸發器插入多行數據?
謝謝你的幫助進行優化。我會試試這個。 – user3109653