MSSQL 触发器
时间:2010-09-20 来源:sarbro
代码
if exists(select * from sysobjects where [name]='Trig_MemberGropu')
drop trigger Trig_MemberGropu
go
create trigger Trig_MemberGropu
on Member
for UPDATE
AS
declare @Score int
declare @MemberID int
IF UPDATE (Score)
select @Score = Score from inserted
select @MemberID= memberID from inserted
if @Score>15000
begin
update Member set groupid=5 where MemberID=@MemberID
end
else if @Score>8000
begin
update Member set groupid=4 where MemberID=@MemberID
end
else if @Score>5000
begin
update Member set groupid=3 where MemberID=@MemberID
end
else if @Score >3000
begin
update Member set groupid=2 where MemberID=@MemberID
end 简单的更新
drop trigger Trig_MemberGropu
go
create trigger Trig_MemberGropu
on Member
for UPDATE
AS
declare @Score int
declare @MemberID int
IF UPDATE (Score)
select @Score = Score from inserted
select @MemberID= memberID from inserted
if @Score>15000
begin
update Member set groupid=5 where MemberID=@MemberID
end
else if @Score>8000
begin
update Member set groupid=4 where MemberID=@MemberID
end
else if @Score>5000
begin
update Member set groupid=3 where MemberID=@MemberID
end
else if @Score >3000
begin
update Member set groupid=2 where MemberID=@MemberID
end 简单的更新
相关阅读 更多 +