List columns by name length in SQL Server database

This query returns columns in a database sorted by their name.


select as column_name,
    len( as column_name_length,
    schema_name(tab.schema_id) as schema_name, as table_name
 from sys.tables as tab
        inner join sys.columns as col 
        on tab.object_id = col.object_id
order by len( desc,


  • column_name - column name
  • column_name_length - column name length
  • schema_name - column table schema name
  • table_name - column table name


  • One row represents one column of each table in a database
  • Scope of rows: each column that exists in a database
  • Ordered by length descrending - from longhest to shortest

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.