如何实现这样的触发器?

迭戈爱足球 2007-03-14 11:34:29
当b.expiredby<getdate()条件成立时,要进行update merchant_info.这个需要在网站的运行中自动更新.如何写.谢谢

以下是sql语句
update merchant_info

set discount=BookDiscount,
promotionTag=-1,
pDiscountType=BdiscountType

where merchantID in

( select distinct b.merchantID from broadcast_info b where b.expiredby<getdate() )
...全文
180 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
txlicenhe 2007-03-14
  • 打赏
  • 举报
回复
当b.expiredby<getdate()条件成立时
------------------------------------
这个条件好象只能用调度,而没办法用触发器。
冷箫轻笛 2007-03-14
  • 打赏
  • 举报
回复
update merchant_info

set discount=BookDiscount,
promotionTag=-1,
pDiscountType=BdiscountType

where merchantID in

( select distinct b.merchantID from inserted b where b.expiredby<getdate() )
迭戈爱足球 2007-03-14
  • 打赏
  • 举报
回复
和大家分享一下我写的.不知道如何.大家说说.我是楼主:



CREATE TRIGGER myTrigger
ON broadcast_info
FOR UPDATE
AS
update merchant_info

set discount=BookDiscount,
promotionTag=-1,
pDiscountType=BdiscountType

from broadcast_info
where merchant_info.merchantID in
( select distinct broadcast_info.merchantID from broadcast_info where broadcast_info.expiredby < getdate() )


GO

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧