How to get SQL Server database name

To get SQL Server database name uses function DB_NAME().

Syntax

DB_NAME ( )


Example

SELECT DB_NAME() ;

Results
tempdb

See also: DB_NAME