score:3

Accepted answer

Is there a reason it needs to be more advanced than just this?

SELECT * FROM sysdatabases WHERE name NOT IN('master', 'tempdb', 'model', 'msdb')

Read More

score:0

Or per this thread:

select * from sys.sysdatabases where dbid>4 and [name] not like '$'

score:1

You should specify them with their owner name. In order to do that, you should join sys.databases with sys.server_principals.

Recent versions can have ReportServer databases as well with contains $ sign in name.

select
  d.name
  ,d.database_id
from
  sys.databases d
join
  sys.server_principals p
  on p.sid = d.owner_sid
where
  p.name <> 'sa' and d.name not like '%$%';

More questions

More questions with similar tag