Agent Jobs

Find Databases Not Part Of AlwaysOn

Here’s a quick query to find databases that haven’t been added to the AlwaysOn configuration. In other words they haven’t been added to the availability group.


select
     'server_name'   = upper(@@servername)
,    'database_name' = upper(sd.name)
from
     master.sys.databases sd
     left join master.sys.dm_hadr_database_replica_cluster_states sdhdrcs on sd.name = sdhdrcs.database_name
where
     sd.name not in (select database_name from master.sys.dm_hadr_database_replica_cluster_states)
     and sd.database_id > 4

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s