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 name | Database name by id |
---|---|
master | master |
See also: T-SQL Functions -> APP_NAME | DB_ID | OBJECT_DEFINITION | OBJECT_ID