If you want to know the list of all databases on sql server, you can use one of the following query or stored procedure.

Code Snippet

SELECT * FROM sys.databases

SELECT * FROM sys.sysdatabases

EXEC sp_databases

EXEC sp_helpdb

EXEC sp_msForEachDB 'PRINT ''?'''


some of these may not work in certain version, it depend on your database server version. Just use the one which work with your server.

author's photo

Author : Blue Cloud

Just a normal software developer who love to write code. Developing professional software since 1999. After working in the software industry for many years, I've started my own website to share knowledges and experiences.

blog comments powered by Disqus