how to get database name windows ms sql code example Example 1: show sql server database EXEC sp_databases Example 2: show databases in sql server EXEC SP_DATABASES