November 15, 2009 at 11:52 pm
Hi,
While running this set of statements,
declare @Amount as int
set @Amount = 1000
print @Amount
begin tran
set @Amount = @Amount + 1000
print @Amount
begin tran
set @Amount = @Amount + 1000
print @Amount
commit tran
set @Amount = @Amount + 1000
rollback tran
print @Amount
I thought that last statement will rollback the the data and set amount variable to "3000". But its printing "4000"... Will rollback transaction not work for variables?
November 16, 2009 at 12:27 am
No, variables are not affected by transactions. This is also true of table variables.
November 16, 2009 at 12:42 am
Just to add to what Lynn has mentioned,
its a variable stored in memory for our operations, where would it 'commit/rollback' it to (no table or anything to go back to!)?
---------------------------------------------------------------------------------
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply