Groups | Blog | Home
all groups > sql server (alternate) > april 2004 >

sql server (alternate) : Connected to which database


Post NO[at]SPAM tophoven.net
4/28/2004 4:02:14 AM
Hello all,

I have a scripts which needs the information about the database in
which it is running.

How can I find out this information.

For example if I want to know the User who has satrted this report, I
use the SYSTEM_USER procedure.

Does an equal procedure exist to find out, on which database the user
is connected to.

Regrads
Dan Guzman
4/28/2004 12:18:57 PM
You can the name of the current database with DB_NAME():

SELECT DB_NAME()

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

AddThis Social Bookmark Button