Search column name in tables

This code is something I used frequently, when I started to work with an old legacy database, with more, than 400 tables.

SELECT		
	c.name  AS 'ColumnName'
	,t.name AS 'TableName'
FROM		
	sys.columns c
INNER JOIN	
	sys.tables  t   
	ON 
		c.object_id = t.object_id
WHERE		
	c.name LIKE '%Column Name%'
ORDER BY	
	TableName, ColumnName

Leave a Reply

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