Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Database name

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-10-24 : 08:29:25
Anand writes "How do I get the name of the database presently I am working on?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-10-24 : 08:30:09
SELECT DB_NAME()

You can also pass a database ID and get that DB's name:

SELECT DB_NAME(2) --returns tempdb
Go to Top of Page
   

- Advertisement -