Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 get Database name

Author  Topic 

Sean_B
Posting Yak Master

111 Posts

Posted - 2007-05-17 : 09:04:29
Hi,

How do I get the database name and the server name from within a database session ?

Sean

sshelper
Posting Yak Master

216 Posts

Posted - 2007-05-17 : 09:06:24
To get the database name, you can use the DB_NAME() function:

SELECT DB_NAME()

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-17 : 09:06:37
[code]
select db_name(), serverproperty('servername')
[/code]


KH

Go to Top of Page

Sean_B
Posting Yak Master

111 Posts

Posted - 2007-05-17 : 09:10:08
Thank you, much appreciated.

Sean
Go to Top of Page
   

- Advertisement -