1. Querying all databases in an instance
Select name,database_id from sys.databases
2. Querying all tables in the database
Select Table_type,table_name from Information_schema.tables ORDER BY table_name
SELECT * from sysobjects where type= ' U ' ORDER by name (all tables)
SELECT * from sysobjects where type= ' SQ ' ORDER by name
SELECT * from sysobjects where type= ' FN ' ORDER by name
SELECT * from sysobjects where type= ' S ' ORDER by name
SELECT * from sysobjects where type= ' D ' ORDER by name
SELECT * from sysobjects where type= ' IT ' ORDER by name
SELECT * from sysobjects where type= ' F ' ORDER by name
SELECT * from sysobjects where type= ' F ' ORDER by name
SELECT * from sysobjects where type= ' PK ' ORDER by name (all primary keys)
SELECT * from sysobjects where type= ' P ' ORDER by name
SELECT * from sysobjects where type= ' TF ' ORDER by name
SELECT * from sysobjects where type= ' C ' ORDER by name
SELECT * from sysobjects where type= ' UQ ' ORDER by name
SELECT * from sysobjects where type= ' V ' ORDER by name (all views)
SQL queries all tables, all columns