This website completely moved to new platform. For latest content, visit www.programmingposts.com

Search this Site

21 Jan 2013

GET ALL DATABASE NAMES EXCEPT SYSTEM DATABASES IN SQL SERVER

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');


AllDatabaseNamesExceptSystemDB





 

Post u may like  : Retrieving List of All DataBases in Sql Server