Saturday, October 2, 2021

Find Column Name From All Tables of Database

Find the column name present in all tables in the database. You use below query to find out.

For Example Column Name: Id present in list of tables in database


SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
    FROM sys.tables AS t
    INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
        where c.name like 'Column Name%'
    ORDER BY schema_name, table_name;

Output:



No comments:

Post a Comment