The sp_MSforeachdb Stored Procedure

The sp_MSforeachdb stored procedure helps you to do repetitive actions against all or some of the SQL Server instance databases.

For example, this query:

EXEC sp_MSforeachdb 'USE [?]; EXEC sp_spaceused'

Displays the space used (Reserved space, Data, index Size, Unused Space) by each database.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: