Friday, February 17, 2012

Connected to which database

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
Franz-JosefYou can the name of the current database with DB_NAME():

SELECT DB_NAME()

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Franz-Josef" <Post@.tophoven.net> wrote in message
news:a0fd39b2.0404280302.403618ee@.posting.google.c om...
> 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
> Franz-Josef

No comments:

Post a Comment