Tag Archives: Execute sql query against all databases

Executing a command against all databases

If you want to run the same command against all databases in an instance there is another undocumented stored procedure called ‘sp_MSforeachdeb’.  This can be used to check the space used by all databases in an instance.  This is especially helpful if you have a server with a ton of databases.  Here’s the syntax to [...]