SHOW DATABASES

SHOW DATABASES displays information about subsites of the current site. The result table can be useful in many programming scenarios, such as when iterating through a collection of sites. The SHOW SITES command is a synonym for SHOW DATABASES.

This command always return same columns. For the complete listing see the SHOW DATABASES reference.

Syntax

SHOW [ALL] {DATABASES | SITES};

Code examples

Get all sites directly beneath the current site and print name and URL.

Print sites

using (var command = new SharePointCommand("SHOW DATABASES", connection))
{
    using (var reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
            Console.WriteLine(reader["Name"].ToString().PadRight(40) + " : " + reader["Url"].ToString());
        }
    }
}

Code result

Customers                                : http://myspsite.com/customers
Economy                                  : http://myspsite.com/economy
Marketing                                : http://myspsite.com/marketing
Sales                                    : http://myspsite.com/sales

Gets all sites within the current site collection and print name and URL.

Print all sites

using (var command = new SharePointCommand("SHOW ALL DATABASES", connection))
{
    using (var reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
            Console.WriteLine(reader["Name"].ToString().PadRight(40) + " : " + reader["Url"].ToString());
        }
    }
}

Code result

Home                                     : http://myspsite.com
Customers                                : http://myspsite.com/customers
Economy                                  : http://myspsite.com/economy
Marketing                                : http://myspsite.com/marketing
Sales                                    : http://myspsite.com/sales


Skip Navigation Links.

Visa     MasterCard