List columns by name length in Azure SQL Database

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


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 - name of the column
  • column_name_length - length of the column name
  • schema_name - schema name of the column table
  • table_name - table name of the column


  • One row: represents one column of each table in a database
  • Scope of rows: each column that exists in a database
  • Ordered by: length descending - from longest 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.