Update to handle snapshots and not try to back them up in any multi-database queries
SELECT DISTINCT
s_mf.database_id
, *
FROM sys.master_files s_mf
INNER JOIN sys.databases s_db
ON s_mf.database_id = s_db.database_id
WHERE s_mf.state = 0 -- Online
AND s_db.source_database_id is null --Eliminate All Snapshots
AND has_dbaccess(db_name(s_mf.database_id)) = 1 -- Only look at databases to which we have access
AND NOT db_name(s_mf.database_id) in ('tempdb', 'master', 'msdb', 'model') --eliminate temp db
No comments:
Post a Comment