CREATE TRIGGER tir_update ON [dbo].[bm_cy_ckbm]
FOR UPDATE
AS
if update(bm)
update cy_cd set lb=aa.bm from inserted aa,deleted bb where bb.bm=cy_cd.lb and aa.除了bm的列=aa.除了bm的列
FOR UPDATE
AS
if update(bm)
update cy_cd set lb=aa.bm from inserted aa,deleted bb where bb.bm=cy_cd.lb and aa.除了bm的列=aa.除了bm的列
FOR UPDATE
AS
if update(bm)
update cy_cd set lb=aa.bm from inserted aa,deleted bb where bb.bm=cy_cd.lb and aa.除了bm的列=bb.除了bm的列
CREATE TRIGGER tir_update ON [dbo].[bm_cy_ckbm]
FOR UPDATE
AS
if update(bm)
update cy_cd set lb=(select bm from inserted) where lb = (select bm from deleted)
update bm_cy_ckbm set bm=aa.bm from 另一个表 where 另一个表.编号=bm_cy_ckbm.编号
哈哈。。看看错不错?
declare @new table(row int identity primary key bm varchar(30))
insert @old(bm) select bm from inserted
insert @new(bm) select bm from deleted
update c set lb=o.bm from cy_cd c inner join @new n on c.lb=n.bm
inner join @old o on o.row=n.row
不过,你是否把inserted和deleted搞反了?
inner join inserted o on o.主键=n.主键
if exists(select * from inserted i where exists(select * deleted where bm=i.bm))
begin
raiseerror('这很可能会死机呦!',16,1)
rollback tran
return
end
好象以上方法都不行
FOR UPDATE
AS
if update(bm)
update cy_cd set lb=(select bm from inserted)
where lb in (select bm from deleted)
ib与是一一对应关系吗?
不是一定有问题