|
-
May 23rd, 2005, 05:55 AM
#1
Thread Starter
Fanatic Member
SQL Server - Current Database
Is there anyway, using ADO (2.6) or T-SQL (SQL Server 2000) to find out the current database when you are connected?
Last edited by simonm; May 23rd, 2005 at 08:51 AM.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
May 23rd, 2005, 06:12 AM
#2
Re: SQL Server - Current Database
 Originally Posted by simonm
Is there anyway, using ADO (2.6) or T-SQL (SQL Server 2000) to find out the current database when you are connected?
Isn't it sitting in text in the CONNECTION STRING? Didn't you build the connection string in code?
-
May 23rd, 2005, 06:29 AM
#3
Thread Starter
Fanatic Member
Re: SQL Server - Current Database
 Originally Posted by szlamany
Isn't it sitting in text in the CONNECTION STRING? Didn't you build the connection string in code?
For the particular application I am building, the user can select which database he wishes to use. However, when connecting to a server, each login may have a default database.
I simply need to be able to query the connection to find out what my current database context is...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
May 23rd, 2005, 06:45 AM
#4
Fanatic Member
Re: SQL Server - Current Database
Use the db_name() function:
That will return the name of the current database.
Chris
Master Of My Domain
Got A Question? Look Here First
-
May 23rd, 2005, 08:51 AM
#5
Thread Starter
Fanatic Member
Re: SQL Server - Current Database
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|