title: ALTER INDEX failed because of QUOTED_IDENTIFIER when running from sp_msForEachTable
body: <p>When I try to rebuild an index on a table:</p>
  
  <pre><code>ALTER INDEX ALL ON [dbo].[Allocations] REBUILD
  </code></pre>
  
  <p>that works fine.</p>
  
  <p>But when I call</p>
  
  <pre><code>EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD'
  </code></pre>
  
  <p>I reach the same same table, and it fails with:</p>
  
  <blockquote>
    <p>Msg 1934, Level 16, State 1, Line 2<br>
    ALTER INDEX failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.</p>
  </blockquote>
  
  <hr>
  
  <p>And to confirm that it's the same table:</p>
  
  <pre><code>EXECUTE sp_msForEachTable 'print ''Rebuilding ?'';
  ALTER INDEX ALL ON ? REBUILD;
  PRINT ''   Done ?'''
  </code></pre>
  
  <p>which gives the results:</p>
  
  <pre><code>Rebuilding [dbo].[SystemConfiguration]
     Done [dbo].[SystemConfiguration]
  Rebuilding [dbo].[UserGroups]
     Done [dbo].[UserGroups]
  Rebuilding [dbo].[Groups]
     Done [dbo].[Groups]
  Rebuilding [dbo].[UserPermissions]
     Done [dbo].[UserPermissions]
  Rebuilding [dbo].[AllocationAdmins]
     Done [dbo].[AllocationAdmins]
  Rebuilding [dbo].[Allocations]
  Msg 1934, Level 16, State 1, Line 2
  ALTER INDEX failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
  </code></pre>
  
  <p>What am I not doing wrong?</p>
  
  <hr>
  
  <p><strong>Note</strong>:</p>
  
  <pre><code>EXECUTE sp_msForEachTable 'DBCC DBREINDEX(''?'')' 
  </code></pre>
  
  <p>works <strong><em>fine!</em></strong></p>