sp_msforeachdb

SQLServerCentral Article

sp_msforeachdb: Improving on an Undocumented Stored Procedure

  • Article

Have you ever wanted to run a query across every database on a server with the convenience of a stored procedure? If so, Microsoft provided a stored procedure to do so. It’s unreliable, outdated, and somewhat obfuscated, though. Let’s improve on it!

(43)

You rated this post out of 5. Change rating

2016-04-15 (first published: )

16,963 reads

Blogs

A New Word: on tenderhooks

By

on tenderhooks – adj. feeling the primal satisfaction of being needed by someone, which...

Ramblings about data communities and your contributions, no excuses

By

I have been active in the data community throughout my career. I have met...

SQL Server Journey till 2025 (brief)

By

Quick Summary for Microsoft SQL Server till 2025, I am fortunate to be part...

Read the latest Blogs

Forums

Simulating Mercury’s Orbital Motion Using Pure T-SQL (NASA 2025 Dataset)

By NKTgLaw

SQL Server is typically viewed as a transactional or analytical database engine. However, it...

Azure SQL Database | CREATE EVENT SESSION [Blocking_Capture] ON DATABASE

By DanielP

Hello, Is there a way in Azure SQL Database to change the 'Blocking Process...

Having a Little Fun at SQL Server Central

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Having a Little Fun at...

Visit the forum

Question of the Day

String Similarity I

On SQL Server 2025, when I run this, what is returned?

SELECT EDIT_DISTANCE_SIMILARITY('SQL Server', 'MySQL')

See possible answers