Get column name length distribution in SQL Server database

Query below returns distribution of column name lengths (number of characters).


select len( as column_name_length,
       count(*) as columns,
       count(distinct tab.object_id) as tables
   from sys.tables as tab
       inner join sys.columns as col 
       on tab.object_id = col.object_id
group by len(
order by len(


  • column_name_length - lenght in characters of column name
  • columns - number of columns with this length
  • tables - number of tables that have columns with this name length


  • One row represents one name lenght (number of characters)
  • Scope of rows: each column length that exists in a database
  • Ordered by length ascending (from 1 to max)

Sample results

If you put it into chart it looks like this:

There are no comments. Click here to write the first comment.