10 Sty

Jak wykonać jedno zapytanie na wszystkich bazach MSSQL ?

How to execute one command on all databases?

Microsoft provides two undocumented Stored Procedures that allow you to process through all tables in a database, or all databases in a SQL Server instance. The first Stored Procedure (SP), „sp_MSforeachtable,” allows you to easily process some code against every table in a single database. The other SP, „sp_MSforeachdb,” will execute a T-SQL statement against every database associated with the current SQL Server instance.

important link:making-a-more-reliable-and-flexible-spmsforeachdb