I am updating about 10 databases from production to development server using the same VBScript with database name as parameter.

It has actual RESTORE statement followed by BACKUP with TRUNCATE, then DBCC SHRINKDATABASE.

Sometimes(not everynight) one of databases (different everytime or same) gives me headache. I am getting error 3023 for BACKUP/ 927 for SHRINK, meaning RESTORE didn't complete.

I am not using Async mode for Execute, but I tried to use Async and cycle till State is not Executing -- it never ends...

Is there the way to find if transaction completed on server or it is still running?