Home All Groups Group Topic Archive Search About

How to find current database

Author
11 Nov 2005 4:20 PM
Boaz Ben-Porat
Is there a way to find out what is the current database?

In Query analizer, you execute "use <db-name>", and you can se the current
database in the combo box. Is the an SQL command to find currrent database ?

Boaz Ben-Porat
Milestone Systems

Author
11 Nov 2005 4:31 PM
Alejandro Mesa
See function DN_NAME in BOL.

Example:

select db_name()
go

DB_NAME http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_da-db_706d.asp


AMB

Show quote
"Boaz Ben-Porat" wrote:

> Is there a way to find out what is the current database?
>
> In Query analizer, you execute "use <db-name>", and you can se the current
> database in the combo box. Is the an SQL command to find currrent database ?
>
> Boaz Ben-Porat
> Milestone Systems
>
>
>
Author
11 Nov 2005 4:36 PM
Alejandro Mesa
Correction:

See function DB_NAME in BOL.


AMB

Show quote
"Alejandro Mesa" wrote:

> See function DN_NAME in BOL.
>
> Example:
>
> select db_name()
> go
>
> DB_NAME
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_da-db_706d.asp
>
>
> AMB
>
> "Boaz Ben-Porat" wrote:
>
> > Is there a way to find out what is the current database?
> >
> > In Query analizer, you execute "use <db-name>", and you can se the current
> > database in the combo box. Is the an SQL command to find currrent database ?
> >
> > Boaz Ben-Porat
> > Milestone Systems
> >
> >
> >
Author
11 Nov 2005 4:31 PM
Aaron Bertrand [SQL Server MVP]
SELECT DB_NAME()


Show quote
"Boaz Ben-Porat" <b**@milestone.dk> wrote in message
news:%23UYynvt5FHA.1000@tk2msftngp13.phx.gbl...
> Is there a way to find out what is the current database?
>
> In Query analizer, you execute "use <db-name>", and you can se the current
> database in the combo box. Is the an SQL command to find currrent database
> ?
>
> Boaz Ben-Porat
> Milestone Systems
>
>

AddThis Social Bookmark Button