A more reliable and more flexible sp_MSforeachdb

Posted by AaronBertrand on SQL Blog See other posts from SQL Blog or by AaronBertrand
Published on Wed, 29 Dec 2010 16:02:00 GMT Indexed on 2010/12/29 16:58 UTC
Read the original article Hit count: 193

I've complained about sp_MSforeachdb before. In part of my "Bad Habits to Kick" series in 2009-10, I described how I worked around its sporadic inability to actually process all of the databases on an instance: http://sqlblog.com/blogs/aaron_bertrand/archive/2010/02/08/bad-habits-to-kick-relying-on-undocumented-behavior.aspx I lumped this in a "Bad Habit" category of relying on undocumented behavior, since - while the procedure does have rampant usage - it is, in fact, both undocumented and unsupported....(read more)

© SQL Blog or respective owner

Related posts about Maintenance

Related posts about sp_MSforeachdb

  • A more reliable and more flexible sp_MSforeachdb

    as seen on SQL Blog - Search for 'SQL Blog'
    I've complained about sp_MSforeachdb before. In part of my "Bad Habits to Kick" series in 2009-10, I described how I worked around its sporadic inability to actually process all of the databases on an instance: http://sqlblog.com/blogs/aaron_bertrand/archive/2010/02/08/bad-habits-to-kick-relying-on-undocumented-behavior… >>> More

  • Making a more reliable and flexible sp_MSforeachdb

    as seen on SQL Server Central - Search for 'SQL Server Central'
    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… >>> More

  • Connect Digest : 2012-07-06

    as seen on SQL Blog - Search for 'SQL Blog'
    I've filed a few Connect items recently that I think are important. In #752210 , I complain that the documentation for DDL triggers suggests that they can prevent certain DDL from being run, which is not the case at all. http://connect.microsoft.com/SQLServer/feedback/details/752210/doc-ddl-trigger-topic-suggests-that-rollbacks-run-before-action… >>> More

  • Connect Digest : 2012-07-06

    as seen on SQL Blog - Search for 'SQL Blog'
    I've filed a few Connect items recently that I think are important. In #752210 , I complain that the documentation for DDL triggers suggests that they can prevent certain DDL from being run, which is not the case at all. http://connect.microsoft.com/SQLServer/feedback/details/752210/doc-ddl-trigger-topic-suggests-that-rollbacks-run-before-action… >>> More

  • The Exceptional EXCEPT clause

    as seen on SQL Blogcasts - Search for 'SQL Blogcasts'
    Ok, I exaggerate, but it can be useful… I came across some ‘poorly-written’ stored procedures on a SQL server recently, that were using sp_xml_preparedocument. Unfortunately these procs were  not properly removing the memory allocated to XML structures – ie they were not subsequently calling… >>> More