Get the column name length distribution in Azure SQL Database

The query below returns the distribution of the column name lengths (number of characters).

Query

select len(col.name) 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(col.name)
order by len(col.name)

Columns

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

Rows

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

Sample results

If you put it into chart, it looks like this:

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