Searching Database for Column Names

2015-09-01 SQL Andrew B. Collier

How to find a table which has a column name matching a certain pattern? I am trying to find my way around a new SQL Server database and I wanted to find all columns with the word “Default” in their name.

SELECT tables.name AS TableName, columns.name AS ColumnName
FROM
				sys.columns AS columns
INNER JOIN
				sys.tables AS tables
ON
				tables.OBJECT_ID = columns.OBJECT_ID
WHERE
				columns.name like '%Default%';
Next: MonthOfJulia Day 3: Variables and Data Types.
Previous: MonthOfJulia Day 2: Development Environments.