Solved

SELECT * FROM sys.databases

Posted on 2013-01-16
7
1,159 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

747 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