I have 100s of SQL instances and there are cases where some databases are excluded from backup in the ola backup job. I am doing an backup audit and want to retrieve the excluded database list in the backup job using sql query. How can I do it ? I can query the commandLog, but bit tricky and may not be 100% accurate.
It would be great if we can put query to exclude databases.
EG:
EXECUTE [dbo].[DatabaseBackup]
@Databases = 'USER_DATABASES, - (Select ExcludeDBName from DBA.dbo.ExcludeDBList)
OR using a table variable:
Declare @BackupExcludeList Table(DatabaseName varchar(100))
insert into @BackupExcludeList(DatabaseName) Select DatabaseName from DBA.dbo.BackupExcludeList
EXECUTE [dbo].[DatabaseBackup]
@Databases = 'USER_DATABASES, @BackupExcludeList = @BackupExcludeList