In SQL Server, you can use the DB_NAME()
function to return the name of the current database, or another specified database.
The way it works is, you pass the ID of the database as an argument, and then the function will return the name of that database. However, if you don’t pass an ID it will return the name of the current database.