There are several ways to look for a column in your SQL Server database.

Alternative 1: INFORMATION_SCHEMA.COLUMNS (T-SQL)


DECLARE @colName NVARCHAR(30)
SET @colName = 'name'

SELECT 
	TABLE_CATALOG	AS 'Database',
	TABLE_SCHEMA	AS 'Schema',
	TABLE_NAME		AS 'Table',
	COLUMN_NAME		AS 'Column'
FROM 
	INFORMATION_SCHEMA.COLUMNS
WHERE 
	COLUMN_NAME LIKE '%' + @colName + '%'

Alternative 2: sys.columns (T-SQL)


SELECT 
	sys.tables.name		AS 'Table',
	sys.columns.name	AS 'Column'
FROM 
	sys.columns 
	INNER JOIN sys.tables 
	ON sys.tables.object_id = sys.columns.object_id
WHERE 
	sys.columns.name LIKE '%' + @colName + '%'

Alternative 3: Object Search (SSMS)

In SQL Server 2000, there was an “Object Search” tool in Query Analyzer to search for objects.

To get to this tool in SQL Server 2000, either
– Go to Tools > Object Search, or
– Press F4

Unfortunately this was removed in SQL Server 2005.

But back again in SQL Server 2008:
– Go to View > Object Explorer Details
– Type object name in the Search bar
– Press Enter to Search

Yay!

VN:F [1.9.22_1171]
Rating: 9.8/10 (8 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 2 votes)
How to Search for Columns in SQL Server, 9.8 out of 10 based on 8 ratings
Be Sociable, Share!