各位前辈帮帮我看看,触发器的问题

donghb8 2004-08-07 05:54:37
CREATE trigger tr_bookinfo_update on book7.dbo.bookinfo
after update
as
if update(bookname) or update(bookprice) or update(isbn) or update(hopemonthsell)
update forum.dbo.bookinfomarc set bookname=a.bookname,bookprice=a.bookprice,isbn=a.isbn,hopemonthsell=a.hopemonthsell
from bookinfo inner join inserted a on bookinfo.bookid=a.bookid

问题是:只要执行更新就全部更新了
...全文
272 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zicxc 2004-08-07
  • 打赏
  • 举报
回复
CREATE trigger tr_bookinfo_update on book7.dbo.bookinfo
after update
as
if update(bookname) or update(bookprice) or update(isbn) or update(hopemonthsell)

update c set bookname=a.bookname,bookprice=a.bookprice,isbn=a.isbn,hopemonthsell=a.hopemonthsell
from bookinfo inner join inserted a on bookinfo.bookid=a.bookid
inner join forum.dbo.bookinfomarc c on ... --这里连接条件根据你的实际填写
yesterday2000 2004-08-07
  • 打赏
  • 举报
回复
CREATE trigger tr_bookinfo_update on book7.dbo.bookinfo
for update
as
if update(bookname) or update(bookprice) or update(isbn) or update(hopemonthsell)
update forum.dbo.bookinfomarc set bookname=a.bookname,bookprice=a.bookprice,isbn=a.isbn,hopemonthsell=a.hopemonthsell
from bookinfo b,inserted a where b.bookid=a.bookid
donghb8 2004-08-07
  • 打赏
  • 举报
回复
不行,我自己试过了
yesterday2000 2004-08-07
  • 打赏
  • 举报
回复
TNN的
改了前面没改后面
CREATE trigger tr_bookinfo_update on book7.dbo.bookinfo
after update
as
if update(bookname) or update(bookprice) or update(isbn) or update(hopemonthsell)
update forum.dbo.bookinfomarc set bookname=a.bookname,bookprice=a.bookprice,isbn=a.isbn,hopemonthsell=a.hopemonthsell
from bookinfo b,inserted a where b.bookid=a.bookid
yesterday2000 2004-08-07
  • 打赏
  • 举报
回复
CREATE trigger tr_bookinfo_update on book7.dbo.bookinfo
after update
as
if update(bookname) or update(bookprice) or update(isbn) or update(hopemonthsell)
update forum.dbo.bookinfomarc set bookname=a.bookname,bookprice=a.bookprice,isbn=a.isbn,hopemonthsell=a.hopemonthsell
from bookinfo b,inserted a on b.bookid=a.bookid


试一下

34,838

社区成员

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

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