存储过程中判断Update是否执行有效,提供了我自己的想法,欢迎大家指导
CnEve 2006-07-25 03:24:08 如:update tab set a = 1 where id = 122
在存储过程中执行了这样的更新,并有效判断此更新是否生效,我当前的方法是:
create proc sp_test @a int, @id int as
declare @aa int
select @aa = a from tab where id = @id --先取出未更新前的a值
update tab set a = @a where id = @id --执行更新
if @@error=0 and @aa!=@a
--字段a更新成功
else
--a未更新