Share via


Jumping between database Name and ID in SQL Server

If you're using DMVs or quering the master Database, you'll need to know your database id, and some query results returned with Database Id and your want to know is this my database ?

a quick jumping between database id and name

From ID to Name

select DB_NAME(1);

From Name to ID

select DB_ID('master');

you'll find this Handy to quick locate the info related to your database

Comments

  • Anonymous
    January 01, 2003
    It's pretty easy to memorize too... thanks.