Using DB_ID and DB_Name Functions
Simple but effective, DB_ID and DB_Name give you a concise way to look up the id of a database from a name, or look up the name of a database from an id. There are times when you'll need to write the join to sys.sysdatabases, but when all you need is a quick conversion, these functions get it done.
|