Get list of databases from SQL Server

How can I get the list of available databases on a SQL Server instance?

Tagged:

Answers

  • Execute:

    SELECT name FROM master.sys.databases
    

    This the preferred approach now, rather than dbo.sysdatabases, which has been deprecated for some time.

    Execute this query:

    SELECT name FROM master.dbo.sysdatabases
    

    or if you prefer

    EXEC sp_databases
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!