I am confused, the last count comes from a table.
The first variable is zero and then it adds one to it.
But the first select the value of first is 2 and i am confused, this is only a simple loop.
SELECT @last = COUNT(*) FROM SOMETABLE
--Testing set to 2
select @last = 2
SELECT @first = 0
SELECT @SOMDATE = DATA1 FROM SOMETABLE WHERE EXTRACT_KEY_ID = '1' --@first print @first ---This is not one it is two BEGIN INSERT INTO SOME TABLE END COMMIT TRANSACTION
IF XACT_STATE() <> 0