• Strange behaviour happens with update cursors.

    First, make sure triggers are not firing in those tables, triggers are the best away to create bugs and strange behaviours in legacy systems.

    Second, caution with null! If there are some rows with null values at AccountID you ill get a bad day at work.

    Third, to catch infinite loops try to select to a temp table and fetch from that temp table, it can ill give you some insight about the data the cursor actually fetched and updating it ill no affect that fetched rows.

    Finally, after you fix the bug (understand why this happens) try to rewrite that query to get rid of that cursor.