Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This wiki page is about an undocumented stored procedure sp_MSForEachDB.
A more detailed list of undocumented stored procedures is at the following wiki -
http://social.technet.microsoft.com/wiki/contents/articles/16975.sql-server-undocumented-stored-procedures.aspx
It is strongly recommended to avoid using undocumented features of SQL Server in your Production environment.
How to exclude databases while using the sp_MSforeachdb stored procedure
http://www.sqlservercurry.com/2010/01/how-to-exclude-databases-while-using.html
6 Common Uses of the undocumented Stored Procedure sp_MSforeachdb
http://www.sqlservercurry.com/2009/04/6-common-uses-of-undocumented-stored.html
- Print all the database names in a SQL Server Instance
- Print all the tables in all the databases of a SQL Server Instance
- Display the size of all databases in a SQL Server instance
- Determine all the physical names and attributes(size,growth,usage) of all databases in a SQL Server instance
- Change Owner of all databases to 'sa'
- Check the Logical and Physical integrity of all objects in the database