How to find a column in your database using SQL Server
I bet there were times when you didn’t know the structure of your database and you were looking for a specific column. Well that happens a lot when you start working on a new project, a new database and so on. A very easy way to find the column you were looking for is by using the below script.
Open a new query window in Microsoft SQL Server and paste in the below query. Make sure you have selected the correct database from the upper left corner of the screen.
Replace EmployeeID in the WHERE clause withe the keyword you need.
Execute the query by pressing F5 or the Execute button.
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 ‘%EmployeeID%’
ORDER BY schema_name, table_name;