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
 SQL Server Development (2000)
 finding current database name

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-03 : 10:07:07
Hagit writes "Is there's a way to detect the databse name i'm curently working on?
i know there is a global variable for the @@SERVERNAME.
but i can't find any stored proc nor global variable to help me get current db_name..."

hagitz
Starting Member

2 Posts

Posted - 2002-01-03 : 10:16:56
yes. but that gives ALL the databases the exists and not ONLY the current one.
the 'db_name' that is shown in the upper box of the query analizer.
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-01-03 : 10:23:09
Hi

Did you try :

select db_name()




Damian
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-01-03 : 10:37:36
quote:

yes. but that gives ALL the databases the exists and not ONLY the current one.
the 'db_name' that is shown in the upper box of the query analizer.



From above: If no ID is specified, the name of the current database is returned.


===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
   

- Advertisement -