In
this blog, we see how to get Database Name
using ID and vice versa using SQL Server
Syntax:
-- Get Name from ID.
SELECT DB_NAME('DatabaseID') AS [DatabaseName from ID];
-- Get ID from Name.
SELECT DB_ID('DatabaseName')) AS [DatabaseID from NAME];
Usage:
-- Get Name from
ID.
SELECT DB_NAME(DB_ID()) AS [DatabaseName from ID];

Join the conversation! Your thoughts help the community grow.