top of page
  • Writer's pictureJagan Mohan Reddy Rajidi

SQL query to display total number of rows for each table in database

Following query displays the total number of rows corresponding to each table in the database.

select 'Table Name',rowcnt 'Total Number of Rows' from sysindexes i
inner join  sysobjects o on
where indid<2
and o.xtype='U'
Order by 'Total Number of Rows' desc

Result of above query is sorted by the row count of table in descending order.


13 views0 comments

Recent Posts

See All

When you create any new object(table, stored procedure, view,...etc.) in database then same object name will be stored in system table Sysobjects. Following query returns all the object names along wi

Sometimes you get a scenario where you know the column name but don't remember which table it belongs to. Following query will search for a given column name in database schema and returns all objects

bottom of page