How to exclude tables from sp_msforeachtable

前端 未结 3 1947
星月不相逢
星月不相逢 2021-01-01 11:23

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\'

3条回答
  •  被撕碎了的回忆
    2021-01-01 11:54

    Simplest syntax I came across to include or exclude schemas and tables:

    exec sp_MSforeachtable 'print ''?''', 
    @whereand='and Schema_Id=Schema_id(''Value'') and o.Name like ''%Value%'''
    

提交回复
热议问题