While i was working with a C# application I got the need of getting all the database names in a ComboBox, I googled 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:



1 thought on “Retrieving List of All DataBases in Sql Server”

Leave a Reply

Your email address will not be published.