Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:41:08+00:00 2026-06-12T02:41:08+00:00

When I try to rebuild an index on a table: ALTER INDEX ALL ON

  • 0

When I try to rebuild an index on a table:

ALTER INDEX ALL ON [dbo].[Allocations] REBUILD

that works fine.

But when I call

EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD'

I reach the same same table, and it fails with:

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.


And to confirm that it’s the same table:

EXECUTE sp_msForEachTable 'print ''Rebuilding ?'';
ALTER INDEX ALL ON ? REBUILD;
PRINT ''   Done ?'''

which gives the results:

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.

What am I not doing wrong?


Note:

EXECUTE sp_msForEachTable 'DBCC DBREINDEX(''?'')' 

works fine!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:41:09+00:00Added an answer on June 12, 2026 at 2:41 am

    Quoted identifier settings are stored against each stored procedure, and sp_MSforeachtable has it defined as OFF. However, you can work around this – by setting it to ON before it executes the re-index:

    create table dbo.T (
        ID int not null,
        constraint PK_T PRIMARY KEY (ID)
    )
    go
    create view dbo.V ( ID)
    with schemabinding
    as
        select ID from dbo.T
    go
    create unique clustered index IX_V on dbo.V(ID)
    go
    ALTER INDEX ALL ON dbo.V REBUILD --Fine
    go
    exec sp_MSforeachtable  'ALTER INDEX ALL ON ? REBUILD' --Errors
    go
    exec sp_MSforeachtable  'SET QUOTED_IDENTIFIER ON;
    ALTER INDEX ALL ON ? REBUILD' --Fine
    

    SET QUOTED_IDENTIFIER:

    When a stored procedure is created, the SET QUOTED_IDENTIFIER and SET ANSI_NULLS settings are captured and used for subsequent invocations of that stored procedure.


    And, of course, insert the usual caveats about sp_MSforeachtable being undocumented, and so you can’t rely on any of its behaviour being stable.


    For DBCC DBREINDEX – all bets are off. DBCC lives in its own little, very customized code world. But, of course, it shouldn’t be relied on for future work either:

    This feature will be removed in a future version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible. Use ALTER INDEX instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having this most annoying issue when I try to rebuild my solution
I try to install iconv module, but it always stay at: ^Cyippeeyippee@mini: server$ npm
I can rebuild and build my application without any errors, but I cannot publish
After I run rake ts:index and try to start the sphinx server I get
How to install source rpm(src.rpm) in fedora? When i try to rebuild spec file
I've been reading a lot about this problem but I get nothing that suggests
I try to implement callback interface with COM techonlogy and have IDL like that:
I am developing a context menu (shell extension), and when I try to rebuild
I'm ultimately looking to rebuild an old website that complies to web standards, and
I have the MvxBindingAttributes.xml in my UI.Droid/Resources/Values but everytime I try to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.