Showing posts with label Sql Query to search columns by name. Show all posts
Showing posts with label Sql Query to search columns by name. Show all posts

Monday, February 1, 2010

Sql server Query to search Columns by name in database

USE AdventureWorks  -- this is the database name in which you want to search
GO




SELECT t.name AS table_name,SCHEMA_NAME(schema_idAS schema_name,c.name AS column_nameFROM sys.tables AS tINNER JOIN sys.columns c ON t.OBJECT_ID c.OBJECT_IDWHERE c.name LIKE '%EmployeeID%' 

-- this is the column name which you want to search


ORDER BY schema_nametable_name;


Courtesy : Pinal Dev