It returns value as NVARCHAR type. This function also is used to find the database name by database Id.
Syntax
SELECT DB_NAME() as CurrentDB
--OR
SELECT DB_NAME(7) As CurrentDB
Obtaining the Current Database Name in SQL Server
It returns value as NVARCHAR type. This function also is used to find the database name by database Id.
Syntax
SELECT DB_NAME() as CurrentDB
--OR
SELECT DB_NAME(7) As CurrentDB