Returning the Current Database ID and Name
This DB_ID function returns the database integer ID and DB_NAME returns the database name
for the current database.
5>
6>
7> SELECT DB_ID('master') DatabaseID, DB_NAME(1) DatabaseNM
8> GO
DatabaseID DatabaseNM
---------- -------------------------------------------------------------------------------------------------------------
-------------------
1 master
(1 rows affected)
Related examples in the same category