--How to find a transaction has effeced
create procedure FundsTransfer_Rowcount
(@Giver int,
@Reciever int,
@AmtBal money
)
as
begin
declare @count1 int,@count2 int
begin tran
update bank set Balance=Balance-@AmtBal where B_id=@Giver
set @count1=@@ROWCOUNT
update bank set Balance=Balance+@AmtBal where B_id=@Reciever
set @count2=@@ROWCOUNT
IF @count1=@count2
begin
commit
print 'Transaction succeded'
end
else
begin
rollback
print 'transaction rolledback'
end
end
exec FundsTransfer_Rowcount 104,105,2000
No comments:
Post a Comment