Table of Contents
Find most used column names in database
Query:
select col.name as ColumnName,
count(*) as Tables,
cast(100.0 * count(*) /
(select count(*) from sys.tables) as numeric(36, 1)) as PercentTables
FROM sys.tables as tbl
INNER JOIN sys.columns as col
ON tbl.object_id = col.object_id
GROUP BY col.name
HAVING count(*) > 1
ORDER BY count(*) DESC
Columns Description:
ColumnName – column name
Tables – number of tables that have particular column name
PercentTables – percentage of tables with column with that name
Sample Output of AdventureWorks2017:
