Add Aaron Bertrand's sp_foreachdb replacement for sp_MSforeachdb into the repo
sp_MSforeachdb isn't great - theoretically, it hits every database whether you want it to or not, including offline databases or read-only databases or system databases. Sometimes you wanna skip those.
In practice, it doesn't even hit every database, either - there are instances where it'll skip databases. That's not great either.
So Aaron Bertrand wrote this, and he's agreed to open-source it into the First Responder Kit repo, plus give credit to MSSQLtips:
https://www.mssqltips.com/sqlservertip/2201/making-a-more-reliable-and-flexible-spmsforeachdb/
I'm glad to hear that. Thank you, Aaron and Brent. I created a version of it that includes an EXCLUDE list for databases. I'll figure out how to contribute it over the weekend.
On Fri, Sep 16, 2016 at 1:44 PM Brent Ozar [email protected] wrote:
sp_MSforeachdb isn't great - theoretically, it hits every database whether you want it to or not, including offline databases or read-only databases or system databases. Sometimes you wanna skip those.
In practice, it doesn't even hit every database, either - there are instances where it'll skip databases. That's not great either.
So Aaron Bertrand wrote this, and he's agreed to open-source it into the First Responder Kit repo, plus give credit to MSSQLtips:
https://www.mssqltips.com/sqlservertip/2201/making-a-more-reliable-and-flexible-spmsforeachdb/
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/448, or mute the thread https://github.com/notifications/unsubscribe-auth/AGi0CFHuSqA1tn7V2UFHLqWeICGVaLD4ks5qqtV6gaJpZM4J_LgO .
Very cool.
Should we add some basic error handling to the procedure? In Aaron's blog post he said that it was a good next step, but he also mentioned that the error handling should be done 'according to the standards and conventions in your environment.'
I don't think that precludes building a basic structure that users can extend, though. Even just 'Script failed to run on X database with this error' would be useful.
@PerfektNerd and @rdameron - awesome! Once we get sp_foreachdb in here, then you can start separate Github issues for those. I'm aiming to do a release in 1-2 weeks with a round of updates - if you don't have those checked in before the release, that's totally okay. We can always let it go live as-is, and improvements can be an ongoing thing. I'm excited to see this happen too!
I have the code ready. It was used at my previous employer without issue. I just have to figure out the git part. ;-)
On Fri, Sep 16, 2016 at 2:01 PM Brent Ozar [email protected] wrote:
@PerfektNerd https://github.com/PerfektNerd and @rdameron https://github.com/rdameron - awesome! Once we get sp_foreachdb in here, then you can start separate Github issues for those. I'm aiming to do a release in 1-2 weeks with a round of updates - if you don't have those checked in before the release, that's totally okay. We can always let it go live as-is, and improvements can be an ongoing thing. I'm excited to see this happen too!
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/448#issuecomment-247667040, or mute the thread https://github.com/notifications/unsubscribe-auth/AGi0CD3fgqdk3Yfdx0qafO8RdYcuIGtYks5qqtl5gaJpZM4J_LgO .
This was added in pull request #534. Will test this week on 2005-2016.
This is in the repo now, closing.