I know that sp_msforeachtable
allows to perform queries on all tables.
I have 100 tables and I want to perform the same query on 97 tables.
I'm using this query: EXEC sp_MSForEachTable "DELETE FROM ?"
Is it possible to exclude certain tables?
I know that sp_msforeachtable
allows to perform queries on all tables.
I have 100 tables and I want to perform the same query on 97 tables.
I'm using this query: EXEC sp_MSForEachTable "DELETE FROM ?"
Is it possible to exclude certain tables?
sp_MSforeachtable is undocumented procedure, but according by that example: http://avinashkt.blogspot.ru/2008/05/useful-operations-with-spmsforeachtable.html you could provide additional second parameter @whereand to limit list of tables.
The query that this gets appended to is the following.
So example syntax would be
Simplest syntax I came across to include or exclude schemas and tables: