Monday, March 26, 2012

How to get the name of the database currently connected to?

I have an application which connects to a sql server database thru a SQL
Server ODBC driver. In the application, I have a database componenet with
its aliasname name set to the name of the ODBC driver. I have several
databses on the server and I need to know if I can get the actual name of
the database I am connecting to?Sam,
Try:
SELECT DB_NAME()
HTH
Jerry
"Sam" <Sam@.discussions.microsoft.com> wrote in message
news:F29D0818-2376-432D-B8AE-F8A734A8199F@.microsoft.com...
>I have an application which connects to a sql server database thru a SQL
> Server ODBC driver. In the application, I have a database componenet
> with
> its aliasname name set to the name of the ODBC driver. I have several
> databses on the server and I need to know if I can get the actual name of
> the database I am connecting to?|||SELECT DB_NAME()
David Portas
SQL Server MVP
--
"Sam" <Sam@.discussions.microsoft.com> wrote in message
news:F29D0818-2376-432D-B8AE-F8A734A8199F@.microsoft.com...
>I have an application which connects to a sql server database thru a SQL
> Server ODBC driver. In the application, I have a database componenet
> with
> its aliasname name set to the name of the ODBC driver. I have several
> databses on the server and I need to know if I can get the actual name of
> the database I am connecting to?|||Try:
select db_name()
go
AMB
"Sam" wrote:

> I have an application which connects to a sql server database thru a SQL
> Server ODBC driver. In the application, I have a database componenet wit
h
> its aliasname name set to the name of the ODBC driver. I have several
> databses on the server and I need to know if I can get the actual name of
> the database I am connecting to?|||Thanks :)
"David Portas" wrote:

> SELECT DB_NAME()
> --
> David Portas
> SQL Server MVP
> --
> "Sam" <Sam@.discussions.microsoft.com> wrote in message
> news:F29D0818-2376-432D-B8AE-F8A734A8199F@.microsoft.com...
>
>

No comments:

Post a Comment