Getting the Disk Usage Statistics for all Tables in a Database

I know, there are standard reports and other GUI tools for doing this task for SQL Server 2005 or later but what about when you need to extract such information from a SQL Server 2000 instance or when you just want to write some code? 🙂 The undocumented stored procedure sp_msforeachtable is here to help … Read more…

How to retrieve size information for all the tables in a SQL Server Database

In an older post, I described how you could rebuild all the indexes of a database in SQL Server by making use of the undocumented stored procedure “sp_MSforeachtable”. Another common task is when you want to retrieve size information for all the tables in a database. Again, by using “sp_MSforeachtable“, you can easily do that … Read more…

Undocumented Stored Procedure sp_MSforeachdb

A really neat undocumented SQL Server stored procedure is sp_MSforeachdb.This stored procedure takes as parameters SQL commands which are then executed against all databases on the current SQL Server instance. A simple example (“Hello World”-style 🙂 is the following which lists all the databases in the current SQL Server instance: exec sp_MSforeachdb@command1=”print ‘?’”; The stored … Read more…