Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Database ID in TSQL

Status
Not open for further replies.

mikemcginty

Programmer
Jul 11, 2002
184
0
0
AU
This may be simple but I just can't find the solution

How do I programmatically (via TSQL) retrieve the DBID of the SQL database I am currently connected to?

Regards

Mike

When you call out for help in the darkness, and you hear a voice in return, you're probably just talking to yourself again!
 
This will do the trick.
Code:
select dbid
from master.dbo.sysdatabases
where name = db_name()

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top