title: How can I use sys.sp_MSforeachtable with different schema?
body: <p>I use <code>SQL Server 2008 R2</code> and I want work with <code>Change Data Capture</code>.</p>
  
  <p>I want run this command for my all <code>Tables</code></p>
  
  <pre><code>EXEC sys.sp_cdc_enable_table 
      @source_schema = N'dbo', 
      @source_name   = N'TestTable', 
      @role_name     = NULL 
  </code></pre>
  
  <p>I write this SQL statement .</p>
  
  <pre><code>Declare @Command NVarchar(Max)
  Set @Command = '
                     EXEC sys.sp_cdc_enable_table 
                                      @source_schema = N''dbo'', 
                                      @source_name   = N''?'', 
                                      @role_name     = NULL 
                  '
  Exec sys.sp_MSforeachtable @Command
  </code></pre>
  
  <p>But I use several <code>Schema</code> in my database ?</p>
  
  <p>How can I use <code>sys.sp_MSforeachtable</code> with different schema ?</p>