sql query get all the db list code example Example 1: show databases in sql server SELECT * FROM SYS.DATABASES Example 2: show sql server database EXEC sp_databases