How to find column names for all tables in all databases in SQL Server

前端 未结 13 593
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 04:30

I want to find all column names in all tables in all databases. Is there a query that can do that for me? The database is Microsoft SQL Server 2000.

13条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 04:48

    Better way for you

    sp_MSForEachDB @command1='USE ?;
    SELECT 
        Table_Catalog 
        ,Table_Schema
        ,Table_Name
        ,Column_Name
        ,Data_Type
        ,Character_Maximum_Length
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME like ''%ColumnNameHere%'''
    

提交回复
热议问题