Query to change 2 statements into a batching job
Your first while loop 

WHILE @i &lt;&gt; 0
BEGIN


Encompasses the second while loop as well. 

The docs on break  show that:


  BREAK exits the current WHILE loop


.

Meaning that you are closing the entire while loop including the nested while loop (WHILE @ii &lt;&gt; 0). You have to close the first while loop before opening the second one.

Add an END before opening the next while loop, for example:

    IF(@totalDeleteCurrentCount &gt;= @totalDeleteLimit)
    BEGIN
        PRINT N'-- Limit Reached on 1st loop';
        BREAK;
    END
    ELSE
        CONTINUE;
END
WHILE @ii &lt;&gt; 0