不要这样用,你这样写:
CREATE TRIGGER 名 on [name]
INSTEAD OF UPdate
AS
if update(c)
begin
update [name] set c=case when b=1 then c else aa.c end from inserted aa where aa.a=[name].a
end或者不用触发器你修改的时候加个where
update [name] set c=yy where b=0
CREATE TRIGGER 名 on [name]
INSTEAD OF UPdate
AS
if update(c)
begin
update [name] set c=case when b=1 then c else aa.c end from inserted aa where aa.a=[name].a
end或者不用触发器你修改的时候加个where
update [name] set c=yy where b=0
on name
for updateupdate name
set c=d.c
from inserted i,deleted d
where name.a=i.a
and name.a=d.a
and i.b=1go条件,a是主键,而且不能修改
改成删除触发器,执行 delete name
Bit 类型 字段中是 1 的不删除,非一的删除。
结果变为:
| a | b | c| ---> | 2 | 1 | 3|
| 1 | 0 | 3| ---> | 3 | 1 | 3|
| 2 | 1 | 3| --->
| 3 | 1 | 3| --->
| 4 | 0 | 3| 写出还是会出问题的。大家不访试试看,
在实际运用中,我的B 字段为是不保护,如果B 值为1的行,则不能更新,删除。
请试试
delete ... where b<>1 不是更简单!如果你要达到那个效果只能用替代操作触发器!CREATE TRIGGER 名 on [name]
INSTEAD OF delete
AS
delete [name] where b<>1 and a in (select a from deleted)
if (select b from deleted) =1
ROLLBACK
这样执行更新一行正确,更新多行出错。
所以改写成:
.................你写的那句我想还是解决不了问题! 你有没有办法,------------------------------------------------------------------我想,不记得自己的说的话的人我是没有办法帮他解决问题喽!
这个你看得明白不? 这也看不明白我看你不要混了。
Bit 类型 字段中是 1 的不删除,非一的删除。
结果变为:
| a | b | c| ---> | 2 | 1 | 3|
| 1 | 0 | 3| ---> | 3 | 1 | 3|
| 2 | 1 | 3| --->
| 3 | 1 | 3| --->
| 4 | 0 | 3| 写出还是会出问题的。大家不访试试看,
在实际运用中,我的B 字段为是不保护,如果B 值为1的行,则不能更新,删除。
请试试