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_idAS 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_nametable_name;

Leave a Reply

Your email address will not be published. Required fields are marked *

one × 4 =

Time limit is exhausted. Please reload the CAPTCHA.

Subscribe to our newsletter and stay up to date with:

  • Latest posts
  • News and Articles
  • Products, Promotions and Giveaways

Get our FREE step by step guide to Building SSRS reports 101

Hide me
Show me
Build an optin email list in WordPress [Free Software]