Blog Detail

04 Mar 2009
Tejas Shah
Today, I came across requirement where I need to perform an action on all of the tables within a database.
For example, How much space occupied by each table. I found undocumented Procedure: sp_MSforEachTable in the master database.
The following script reports the space used and allocated for every table in the database.
USE AdventureWorks;
EXECUTE sp_MSforeachtable 'sp_spaceused [?]'
So, We can use sp_MSforeachtable procedure when we need to loop through each table.
Let me know if it helps you in any way.

About me

User

Tejas Shah

Microsoft Certified Professional Expert. I have 14+ years of experience in Design and Develop 100+ .Net applications using Asp.Net, C#, Asp.Net Core, VB.Net, SQL Server, MVC, AngularJS, JavaScript, Azure, HTML5 and CSS3.