List tables with the largest number of columns in Azure SQL Database

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

Table of Contents:

    The query below returns tables with their number of columns, ordered from highest to lowest.


    select schema_name(tab.schema_id) + '.' + as [table], 
           count(*) as [columns]
       from sys.tables as tab
            inner join sys.columns as col
                on tab.object_id = col.object_id
    group by schema_name(tab.schema_id), 
    order by count(*) desc


    • table - name of the table (with schema name)
    • columns - number of columns in table


    • One row: represents one table in a database
    • Ordered by: number of columns in descending order - from tables with the largest number of columns to the lowest

    Sample results

    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.