只在insert操作时触发?
create trigger trg_Account on Account_Account
for insert
as
begin
update a
set
Fk_LevelId=c.Fk_LevelId
from
Account_Account a,inserted a,Account_DealerMemberCentLevel b
where
a.Pk_AccountId = b.Pk_AccountId
and
b.Cents>=c.Cents
and
not exists(select 1 from Account_DealerMemberCentLevel where Cents>=b.Cents and Cents<c.Cents)
end
go
create trigger trg_Account on Account_Account
for insert
as
begin
update a
set
Fk_LevelId=c.Fk_LevelId
from
Account_Account a,inserted a,Account_DealerMemberCentLevel b
where
a.Pk_AccountId = b.Pk_AccountId
and
b.Cents>=c.Cents
and
not exists(select 1 from Account_DealerMemberCentLevel where Cents>=b.Cents and Cents<c.Cents)
end
go
怎么出现4个1呢?
for insert
as
begin
update a
set
Fk_LevelId=c.Pk_LevelId
from
Account_Account a,inserted b,Account_DealerMemberCentLevel c
where
a.Pk_AccountId = b.Pk_AccountId
and
b.Cents>=c.Cents
and
not exists(select 1 from Account_DealerMemberCentLevel where Cents>=b.Cents and Cents<c.Cents)
end
go
for insert
as
begin
update a
set
Fk_LevelId=(select top 1 Pk_LevelId
from Account_DealerMemberCentLevel
where Cents<=b.Cents
order by Cents desc
)
from
Account_Account a,inserted b
where
a.Pk_AccountId = b.Pk_AccountId
end
go