Solved

SELECT * FROM sys.databases

Posted on 2013-01-16
7
1,174 Views
Last Modified: 2013-01-16
In running the query below, does the resulting list of databases mean that each database on a SQL server has a table which lists the other co-located databases? Or, is this query actually getting data external to the database itself?

SELECT * FROM sys.databases

Thank you!
JohnD
0
Comment
Question by:johndarby
7 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 50 total points
ID: 38784684
its actually fetching the data from 'sys' views;
0
 
LVL 39

Expert Comment

by:lcohan
ID: 38784689
"Contains one row per database in the instance of Microsoft SQL Server."


http://msdn.microsoft.com/en-us/library/ms178534(v=sql.100).aspx
0
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 100 total points
ID: 38784705
For further reading on the sys.* views, you may also want to check out:

http://msdn.microsoft.com/en-us/library/ms174365
http://msdn.microsoft.com/en-us/library/ms177862

sys.databases isn't actually a table, it's a system view and what you can see in it depends upon your security on the user you're running the query as
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:johndarby
ID: 38784732
Thank you, each! I am feeling a bit dense here...WHERE is the (meta)data stored? In the MASTER DB?
0
 
LVL 1

Author Comment

by:johndarby
ID: 38784775
lcohan, I se your answer, and from whence you quoted the line, but it seems odd that each SQL Server DB would have one row of system data inscribed into each?
0
 
LVL 39

Accepted Solution

by:
lcohan earned 350 total points
ID: 38784817
Yes is in a master DB table hidded since 2005 and up so they can't be modified anymore. One Row per each database indeed and they are inserted at db creation time. Mode details in select * from sys.database_files for each physical file - just run the query inside each db on that server.
0
 
LVL 1

Author Closing Comment

by:johndarby
ID: 38784916
Thank you for the splendid education! :)
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now