Reason for @@TRANCOUNT check? we're using the SQL functions from Ola Hallengren since many years. Sometime between 2015 and 2018 the check for open transactions was added in IndexOptimize. So now, after upgrade to the current version, the sp fails with "The transaction count is not 0."

Question: What's the functional reason for the check? It seems to me, that the old version w/o the check was running fine too. Is it safe to remove the check?

Regards
Holger
My guess is that you are running IndexOptimize within an existing transaction.  Ola's script is checking for an open transaction close to the very start of the procedure.

Would you really want the IndexOptimize process running under ONE transaction and possibly filling up the log along with possible blocking.

Ola's code has a variety of begin transaction and commit statements.  If the process is already running under a transaction, additional begin transaction statements create nested transactions and the subsequent commit statements only decrement the @@trancount, but don't actually commit the work.

Try running the process without an explicit begin transaction.