Sql-server – How to skip databases with Ola.Hallengren’s scripts

ola-hallengrensql servert-sql

I have a few databases in which the frontend application manages certain maintenance tasks. In this particular instance, I'm running the INDEX OPTIMIZE job every night and every so often it clashes with the application and fails.

The following is the error that I receive:

Msg 50000, Level 16, State 1, Server MyTestServer01, Procedure CommandExecute, Line 152
Msg 2550, The index "clidx_StatisticalInterface_dPollTime" (partition 1) on table "StatisticalInterface" cannot be reorganized because it is being reorganized by another process.

I know that there are times where the vendor would rather their builtin solution manage the maintenance. I'm sure I could find that feature in the application and turn it off, but this question is in case that I can not.

How would I configure or edit this job to ignore a specific database or a list of databases in the same instance?

Best Answer

Sure can. In the job, you'll see @Databases='USER_DATABASES'. Just switch it to @Databases='USER_DATABASES,-Db1' any that you don't need to be optimized, place a '-' in front of.

enter image description here

Take a look at the parameters list listed on his website:

https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html