To get the name of the current database used while running the query:
SELECT DB_NAME() AS Database_Name
To get the current Database ID used while running the query:
SELECT DB_ID() AS Database_ID
To see how to get Database Name from Database ID and Database ID from Database Name in SQL Server read related article:
Get Database Name from Database ID and Database ID from Database Name in SQL Server