There are several ways to get the list of user-created databases in SQL Server, including just by expanding the Databases tree in Object Explorer in SSMS. However, if your SQL Server has hundreds of databases (like a shared web hosting service), it is not an ideal way to rely on the object explorer in SSMS. In such situation a select statement comes in handy to generate a list. Here is a select statement, I use to get the list of databases created by the users on a server.
SELECT name ,dbid FROM sys.sysdatabases WHERE dbid > 4
In the above statement, the filter dbid > 4 is used to eliminate the system databases from the list.
More SQL Server Tips here.
- Read more about sys.sysdatabases at Microsoft Docs.