Displays the name of the database with the specified ID number.
db_name([database_id])
is a numeric expression for the database ID (stored in sysdatabases.dbid).
Returns the name of the current database:
select db_name()
Returns the name of database ID 4:
select db_name(4)
------------------------------ sybsystemprocs
db_name, a system function, returns the database name.
If no database_id is supplied, db_name returns the name of the current database.
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute db_name.
Documentation Transact-SQL Users Guide
Functions col_name, db_id, object_name