Returning the Current Database ID and Name : DB_ID « System Settings « SQL Server / T-SQL Tutorial






4> SELECT DB_ID() DatabaseID, DB_NAME() DatabaseNM
5> GO
DatabaseID DatabaseNM

---------- -------------------------------------------------------------------------------------------------------------
-------------------
         1 master


(1 rows affected)








26.5.DB_ID
26.5.1.Returning the Current Database ID and Name