• When @filecounter = 0 we only see the value of @BackupFilePattern. The next line is --EXEC(@BackupFilePattern).

    When you remove the -- you will see why @filecounter = 0.

    Kees