Find Number of Rows in all table at once SQL Server

preview_player
Показать описание
In this video I have explained how can you find total number of records in all tables in a database, and how can you find all the empty tables in the database.

Here is the query I have used :

;WITH EmptyRows As
(
Select SUM(row_count) As [TotalRows],
OBJECT_NAME(Object_ID) As TableName
Where index_id = 0 Or index_id=1
Group By Object_ID
)

Select * from EmptyRows
Where TotalRows = 0
Order By TotalRows

Above query will return all the empty table, to find total row count please change the Where condition accordingly.
Рекомендации по теме
Комментарии
Автор

i did not uderstand what is sys.dm_db_partition_stats

TheVjnathan