5

Is there a way to exclude Standby or Read only databases from Index maintenance and also from backups using Ola Hallengren scripts.

asked Dec 5, 2017 at 11:48

1 Answer 1

5

It's available for backups.

NUTS

Though it's a somewhat recent addition, so you may need to upgrade your scripts.

For index maintenance, database status is checked so commands don't actually run on databases that aren't fully accessible.

IF DATABASEPROPERTYEX(@CurrentDatabaseName,'Status') = 'ONLINE'
AND (@CurrentIsDatabaseAccessible = 1 OR @CurrentIsDatabaseAccessible IS NULL)
AND DATABASEPROPERTYEX(@CurrentDatabaseName,'Updateability') = 'READ_WRITE'
BEGIN

Hope this helps!

answered Dec 5, 2017 at 12:40
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.