MEA Center of Expertise

We are a 120+ technology enthusiasts helping Microsoft customers around Middle-East & Africa region. We bridge Microsoft tools & technologies to their businesses.

Jumping between database Name and ID in SQL Server

Jumping between database Name and ID in SQL Server

  • Comments 1
  • Likes
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
  • It's pretty easy to memorize too... thanks.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment