SQL script to get table name with with highest number of records

 SELECT 

    [TableName] = so.name, 
    [RowCount] = MAX(si.rows) 
FROM 
    sysobjects so, 
    sysindexes si 
WHERE 
    so.xtype = 'U' 
    AND 
    si.id = OBJECT_ID(so.name) 
GROUP BY 
    so.name 
ORDER BY 
    2 DESC

Comments

Popular posts from this blog

D365/Ax7 Data Entity error : Results. Field 'Invoice account' must be filled in. Results. validateWrite() failed on data source "Tablename"

D365/AX7 - Can not rename database - The database could not be exclusively locked to perform the operation