Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - INFORMATION_SCHEMA for All Databases On Server

INFORMATION_SCHEMA.TABLES or INFORMATION_SCHEMA.COLUMNS work for only specified databases.

Is it possible to query table metadata for ALL databases on server by using INFORMATION_SCHEMA?

like image 342
Ahmet Altun Avatar asked Apr 26 '11 07:04

Ahmet Altun


People also ask

How can I see all databases in SQL Server?

Use SQL Server Management Studio In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance. To see a list of all databases on the instance, expand Databases.

How do I get all the schema names in a SQL Server database?

You can get a list of the schemas using an SSMS or T-SQL query. To do this in SSMS, you would connect to the SQL instance, expand the SQL database and view the schemas under the security folder. Alternatively, you could use the sys. schemas to get a list of database schemas and their respective owners.

What is the INFORMATION_SCHEMA in SQL Server?

Information schema views provide an internal, system table-independent view of the SQL Server metadata. Information schema views enable applications to work correctly although significant changes have been made to the underlying system tables.


1 Answers

You can do this only by using dynamic query for database iteration. One way is using ms_ForEachDB stored procedure, second is querying sys.databases dynamic view.

like image 144
Dalex Avatar answered Sep 24 '22 07:09

Dalex