• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
成为自己最想成为的那种人
博客园    首页    新随笔    联系   管理    订阅  订阅
SQL Server 创建触发器(trigger)

update 触发器:

if(OBJECT_ID('trigger_compost_up') is not null)
drop trigger trigger_compost_up
go 
create trigger trigger_compost_up
on t_com_post                -- 指定创建触发器的表
for update                     -- update 触发器,也可以写为 after update
as 

declare @postid int 
declare @postName nchar(40)

if UPDATE(name)
begin
    select @postid = id from deleted
    select @postName = name from inserted
    update t_post_detailinfo set postName = @postName where postid = @postid
end

 

posted on 2018-03-01 12:04  遇见未来  阅读(447)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3