Get the column name length distribution in Azure SQL Database

Rene Castro - Dataedo Team Rene Castro 2018-12-10

Table of Contents:


    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:

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

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy.
    Accept