Thursday 30 July 2015

Quickest way to Get Row Count of All Tables from a SQL Server Database

In this tip we will see an approach which can be used to get the Table Row Counts without writing any explicit queries.
  • Open SQL Server Management Studio (SSMS)
  • Connect to the SQL Server Instance from which you want to get the Row Counts
  • Go to View | Object Explorer Details (or alternatively, you can press F7)
  • In the Object Explorer, navigate to Tables folder under the database (say AdventureWorksDW) from which you wan to get the Row Counts (Databases | AdventureWorksDW | Tables)
  • Object Explorer Details window shows a summary of all the Tables (present in the Tables folder under AdventureWorksDW database) as shown in the below screenshot.
Now, in the Object Explorer Details window, Right Click on the header and select Row Count from the context menu as shown in the below screenshot.
Now you will see the Row Count of all the Tables in the Object Explorer Details window as shown below.

Also, in the above displayed view, you can select multiple rows and copy the information into an excel or any other format for further reporting/auditing purposes, and you can add or remove the columns as required like we added the Row Count column above. This is a very hand approach for getting the Row Count from all the tables in a SQL Server database.

No comments:

Post a Comment