用存储过程好了。我做了一个,仅供参考
t3表两个字段name char 10,money int
存储过程如下
CREATE PROCEDURE t3in
@name nchar(10),
@money int
AS
declare @tmpmoney int
declare cur cursor local for
select money from t3 where name = @name
open cur
fetch next from cur into @tmpmoney
if @@fetch_status<>-1
begin
select @money = @money + @tmpmoney
delete from t3 where name = @name
insert into t3 (name,money) values (@name,@money)
end
close cur
deallocate cur
执行添加如下调用exec t3in '1',20
和你想要的效果一样,就是麻烦了点,不知道哪位大侠有更好的办法