patternsqlMinor
Excluding Read only databases using Ola Hallengren script
Viewed 0 times
scriptdatabasesreadexcludinghallengrenusingolaonly
Problem
Is there a way to exclude Standby or Read only databases from Index maintenance and also from backups using Ola Hallengren scripts.
Solution
It's available for backups.
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.
Hope this helps!
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'
BEGINHope this helps!
Code Snippets
IF DATABASEPROPERTYEX(@CurrentDatabaseName,'Status') = 'ONLINE'
AND (@CurrentIsDatabaseAccessible = 1 OR @CurrentIsDatabaseAccessible IS NULL)
AND DATABASEPROPERTYEX(@CurrentDatabaseName,'Updateability') = 'READ_WRITE'
BEGINContext
StackExchange Database Administrators Q#192419, answer score: 5
Revisions (0)
No revisions yet.