Unix Technical Forum

Connected to which database

This is a discussion on Connected to which database within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello all, I have a scripts which needs the information about the database in which it is running. How ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 02:38 AM
Franz-Josef
 
Posts: n/a
Default 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-Josef
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 02:38 AM
Dan Guzman
 
Posts: n/a
Default Re: Connected to which database

You 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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:20 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com