用数据分析器 查询分析 执行下面语句
---创建触发器,每分钟为在线玩家仓库加50000钱
Create Trigger [美U在线送钱] ON dbo.[MEMB_STAT]
After Update
As
declare @memb___id varchar(10)
declare @ConnectStat tinyint
declare @ConnectTM datetime
declare @DisConnectTM datetime
declare @ConnectStat2 tinyint
declare @DisConnectTM2 datetime
declare @AddMoney int
select @memb___id=memb___id,
@ConnectStat=ConnectStat,
@ConnectTM=ConnectTM,
@DisConnectTM=DisConnectTM
from Inserted
select @ConnectStat2=ConnectStat,
@DisConnectTM2=DisConnectTM
from Deleted
IF (@ConnectStat < @ConnectStat2) and (@DisConnectTM > @DisConnectTM2) and (@ConnectTM < @DisConnectTM)
Begin
Set @AddMoney = datediff(minute,@ConnectTM,@DisConnectTM)*50000---这个数字你自己定,想发多少你自己定
UpDate Warehouse set [money]=(case when 2000000000-@AddMoney >[money] then [money]+@AddMoney else 2000000000 end)
where accountid=@memb___id
End
Go
|
|