请帮我写一下这个触发器,万分感谢!

kncomputer 2003-05-25 12:57:34
表t1——字段:id, thename
表t2——字段:id,t1id,thename,IsUsing
现希望创建触发器,当删除t1的记录时,希望把t2中t1id等于刚才删除的t1的id的记录的IsUsing改为0,
也就是说:
当:delect t1 where id=5时,希望让触发器:
update t2 set IsUsing = 0 where t1id=5

这触发器:
create trigger theTRIGGER
on t1
for delect
as

接着怎么写啊?谢谢!万分感谢。
...全文
12 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-05-25
  • 打赏
  • 举报
回复
create trigger theTRIGGER on t1
for delect
as
update t2 set IsUsing = 0 where t1id in (select id from deleted)

34,588

社区成员

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

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