Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
database query
database query
Rate Topic
Display Mode
Topic Options
Author
Message
bryan van ritter
bryan van ritter
Posted Tuesday, March 31, 2009 3:52 AM
SSC Journeyman
Group: General Forum Members
Last Login: Monday, April 01, 2013 12:35 AM
Points: 82,
Visits: 443
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
Post #686821
Adi Cohn-120898
Adi Cohn-120898
Posted Tuesday, March 31, 2009 4:08 AM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 2:19 AM
Points: 2,018,
Visits: 4,915
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/
Post #686827
Grant Fritchey
Grant Fritchey
Posted Tuesday, March 31, 2009 4:59 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 4:17 AM
Points: 13,377,
Visits: 25,161
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
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #686862
bryan van ritter
bryan van ritter
Posted Tuesday, March 31, 2009 5:45 AM
SSC Journeyman
Group: General Forum Members
Last Login: Monday, April 01, 2013 12:35 AM
Points: 82,
Visits: 443
Hi Adi,
thanks for your reply, just what i was looking for. thanks again.
bryan
Post #686902
bryan van ritter
bryan van ritter
Posted Tuesday, March 31, 2009 5:46 AM
SSC Journeyman
Group: General Forum Members
Last Login: Monday, April 01, 2013 12:35 AM
Points: 82,
Visits: 443
Hi Grant,
thanks for the remark. just like Adi suggested worked for me.
bryan
Post #686905
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.