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

Search this Site

21 Jan 2013

Retrieving List of All DataBases in Sql Server

While i was working with a c# application i got the need of getting all the database names in a combo box, i searched net and found some queries to get the list of all database names.

If you are working on master database, the query will be any one of the queries given below..


SELECT name FROM sysdatabases

SELECT name FROM sys.databases


If you are working with any databases including master , there are few queries to get the names of all databases, you can use any of them

SELECT name FROM sys.sysdatabases

SELECT name FROM master.sys.databases

SELECT name FROM master..sysdatabases

SELECT name FROM master.sys.sysdatabases


Output will be as in the image below:

AllDatabaseNames


Post u may like:

Query to get ALL DATABASE NAMES EXCEPT SYSTEM DATABASES

1 comment:

Thanks for your comments.
-Sameer