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.

    Query

    select schema_name(tab.schema_id) + '.' + tab.name 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), 
           tab.name
    order by count(*) desc
    

    Columns

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

    Rows

    • 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

    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