Get all table names and their row counts

SQL Server

 

Famous database from Microsoft. Skyvia requires the server to be available from Internet.

List of all tables in database and their row counts

Query Text

SELECT
    SC.Name + '.' + T.Name TableName,
    SUM(P.rows) RowCnt
FROM 
    sys.tables T
INNER JOIN 
    sys.partitions P ON P.OBJECT_ID = T.OBJECT_ID
INNER JOIN 
    sys.schemas SC ON T.schema_id = SC.schema_id
WHERE 
    T.is_ms_shipped = 0 AND
    P.index_id IN (1, 0)
GROUP BY
    SC.Name, T.Name
ORDER BY
    SUM(P.rows) DESC
  

Open Query