This is probably due to nested transaction. Have a look at the following link. This article will provide you more info on it:
SQL Server Transactions and Error Handling[
^]
By the way... it is obvious that all other nested transactions are rolled back because of the while that does a rollback on everything.
You would need to determine how far you are already nested when starting this script:
DECLARE @TransactionCount INT;
SET @TransactionCount = @@TRANCOUNT
and use that value to rollback only those transactions:.
WHILE @@TRANCOUNT > @TransactionCount BEGIN
ROLLBACK
END
Good luck!