There is a simple query to get all database names except system databases.
You can use any one of them given below..
SELECT name FROM sys.databases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM sys.sysdatabases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM master.sys.databases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM master..sysdatabases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM master.sys.sysdatabases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
Post u may like : Retrieving List of All DataBases in Sql Server
You can use any one of them given below..
SELECT name FROM sys.databases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM sys.sysdatabases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM master.sys.databases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM master..sysdatabases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
SELECT name FROM master.sys.sysdatabases WHERE
name NOT IN ('master', 'tempdb', 'model', 'msdb');
Post u may like : Retrieving List of All DataBases in Sql Server
[...] query to get ALL DATABASE NAMES EXPECT SYSTEM DATABASES [...]
ReplyDelete