SQL Server sp_msforeachtable usage to select only those tables which meet some condition

You know how sp_MSforeachtable is undocumented, and may go away at any time/be modified? Well, if you’re happy to ignore that, it has another parameter called @whereand, which is appended to the WHERE clause of the internal query that is being used to find the tables (and should start with an AND). You also have … Read more