Getting Current Database Name and ID using SQL Server
In
this blog, we see how to get ID and Name of current Database using SQL Server
SQL Snippet:
--To get the
current database name
SELECT DB_NAME() AS [Database NAME];
--To get current
database id
SELECT DB_ID() AS [Database ID];
OUTPUT:
Database NAME
------------------
Northwind
(1 row(s) affected)
Database ID
-----------
26
(1 row(s) affected)
Thanks for reading :)

Join the conversation! Your thoughts help the community grow.