Get the databases that are not part of any availability groups (AlwaysOn)

Hello,

I am trying to all databases that are not part of any availability groups (AlwaysOn) using T-SQL.

i tried but i found only 1 way to do it

first is to get all databases on the server

Select name from sys.databases

then get all databases that are part of the availability groups

Select * from sys.availability_databases_cluster

then get the differences manually

is there is any statement that can get the databases that are not part of any availability groups (AlwaysOn) directly ?

A very quick and dirty way will be:

select [name] from sys.databases
where [name] not in (select database_name from sys.availability_databases_cluster)
and [name] not in ('master', 'msdb', 'model', 'tempdb')