Fetch Row Count for All Tables in a SQL SERVER

Using a short query we can list all the tables in the database along with the number of records in each table.

commit 498f334 · authored · 1 min read

Fetch Row Count for All Tables in a SQL SERVER

Just execute the below query in the database to see the list of tables and number of records in each table.

SELECT t.name, s.row_count
FROM sys.tables t
JOIN sys.dm_db_partition_stats s
ON t.object_id = s.object_id
AND t.type_desc = 'USER_TABLE'
AND s.index_id IN (0,1)

local graph · open full graph

"Fetch Row Count for All Tables in a SQL SERVER" is connected to the topics SQL Server and related to 8 other entries. Style Guide - SQL Server Auditing Column Names Style Guide - SQL Server Au… SQL Server - Delete Duplicate Rows SQL Server - Delete Duplica… Dapper - Execute Multiple Stored Procedures Dapper - Execute Multiple S… Create SQL Server Database From a Script in Docker-Compose Create SQL Server Database … Microsoft SQL Server Guy Trying Oracle Database Microsoft SQL Server Guy Tr… Docker - SQL Error on ASP.NET Core Alpine Docker - SQL Error on ASP.N… Create New Database Level User Create New Database Level U… UTC to UAE Time (Arabian Standard Time) UTC to UAE Time (Arabian St… SQL Server #sql-server Fetch Row Count for All Tables in…

comments

loading discussion…