March 31, 2009 at 3:52 am
hello,
i'am trying to create a query which gives me back the database name and the instancename of that particular database and put all of this in a table. can someone help me with this issue.
kind regard,
bryan
March 31, 2009 at 4:08 am
It isn’t very clear what you want to do. Do you want to get a list of databases in the instance? If this is what you want you can use this query:
select @@servername, name from master.sys.databases
If you want something else, pleas specify.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 31, 2009 at 4:59 am
As the last post showed, @@ServerName gets you the name of the server, DB_NAME() gets you the current database. If you pass it a database ID, it will get any other database name.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
March 31, 2009 at 5:45 am
Hi Adi,
thanks for your reply, just what i was looking for. thanks again.
bryan
March 31, 2009 at 5:46 am
Hi Grant,
thanks for the remark. just like Adi suggested worked for me.
bryan
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply