T-SQL Tutorial

DB_NAME() Metadata Function


DB_NAME returns a nvarchar type that is the database name.

DB_NAME() Syntax:

DB_NAME()
DB_NAME ( [ database_id ] )

DB_NAME() Example:

SELECT DB_NAME() AS 'Database name',
DB_NAME (1) AS 'Database name by id';

Database nameDatabase name by id
mastermaster

See also: T-SQL Functions -> APP_NAME | DB_ID | OBJECT_DEFINITION | OBJECT_ID