-- Get Name from ID.
SELECT DB_NAME('DatabaseID') AS [DatabaseName from ID];
-- Get ID from Name.
Usage:
-- Get Name from
ID.
SELECT DB_NAME(DB_ID()) AS [DatabaseName from ID];
-- Get ID from
Name.
DatabaseName from ID
------------------------
Northwind
(1 row(s) affected)
DatabaseID from NAME
--------------------
26