I know that sp_msforeachtable allows to perform queries on all tables.
sp_msforeachtable
I have 100 tables and I want to perform the same query on 97 tables.
I\'
EXEC sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN ( ISNULL(OBJECT_ID(''[dbo].[T1]''),0), ISNULL(OBJECT_ID(''[dbo].[T2]''),0) ) DELETE FROM ?'