Making a more reliable and flexible sp_MSforeachdb

Posted on SQL Server Central See other posts from SQL Server Central
Published on Tue, 18 Jan 2011 07:00:00 UT Indexed on 2011/01/28 23:33 UTC
Read the original article Hit count: 150

Filed under:
While the system procedure sp_MSforeachdb is neither documented nor officially supported, most SQL Server professionals have used it at one time or another. This is typically for ad hoc maintenance tasks, but many people (myself included) have used this type of looping activity in permanent routines. Sadly, I have discovered instances where, under heavy load and/or with a large number of databases, the procedure can actually skip multiple catalogs with no error or warning message. Since this situation is not easily reproducible, and since Microsoft typically has no interest in fixing unsupported objects, this may be happening in your environment right now

© SQL Server Central or respective owner