SOLVED (my own problem):
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
This worked for me.
As following the tutorial on the Microsoft website here, I’ve found it quite easy to loop through the rows of a table using the following code.
@{
var data = Database.Open("FullDatabase").Query("SELECT * FROM Servers");
}
<div id="movieslist">
<ol>
@foreach(var row in data)
{
<li><a href="#">@row.Item</a></li>
}
</ol>
</div>
Which outputs the following:
1. Virtual Machines
2. Physical Machines
3. Processors (CPU)
4. Memory (RAM)
5. OS Build
However, the “Servers” table is just one of many in the database. What I would love to do is something like this:
@{
var database = Database.Open("FullDatabase")
}
<div id="movieslist">
<ol>
@foreach(var table in database)
{
var data = database.Query("SELECT * FROM " + table);
@foreach(var row in data)
{
<li><a href="#">@row.Item</a></li>
}
}
</ol>
</div>
Is such a thing possible? If so how? Thanks very much.
First of all, that’s just something you do for fun, and never, ever in production sites, as you should only retrieving what you really want, and not wast any more bandwidth / time consuming all the things you don’t need.
Secondly, you can always query the system data and for get all tables to the board, you just issue a SELECT statement like:
or
or
They all do the same, depending on what SQL Version you are using…
So your
databasequery would look like: