sqlsql-serverazure-sql-database

Search a column in database


Suppose I have a database My_DB with hundreds of tables.

Now, I need to find about a particular column My_Emp_ID in my database.

I tried manually searching each table, but it is not efficient.

What is the best way to find all the tables that contain column My_Emp_ID ?

You can assume that schema is same for all the tables present in the database.

Thanks.


Solution

  • select * 
    from INFORMATION_SCHEMA.COLUMNS
    where COLUMN_NAME = 'My_Emp_ID'