Skip to content

Instantly share code, notes, and snippets.

@dariusz-wozniak
Created July 7, 2021 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dariusz-wozniak/7bb63480fd441cd656f7a206441fdbc2 to your computer and use it in GitHub Desktop.
Save dariusz-wozniak/7bb63480fd441cd656f7a206441fdbc2 to your computer and use it in GitHub Desktop.
List user server databases in SQL Server
SELECT *
FROM master.sys.databases
WHERE Cast(CASE WHEN name IN ('master', 'model', 'msdb', 'tempdb') THEN 1 ELSE is_distributor END As bit) = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment