SQL - INFORMATION_SCHEMA for All Databases On Server

Ahmet Altun picture Ahmet Altun · Apr 26, 2011 · Viewed 12.2k times · Source

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?

Answer

Dalex picture Dalex · Apr 26, 2011

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.