Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am have been using this procedure to reorganize the indexes in all my tables for a database:

SQL
EXEC sp_MSforeachtable @command1="print 'Reorganizing indexes for ?' ALTER INDEX ALL ON ? REORGANIZE"
GO


I ran into this issue where there was an error performing this operation:

Reorganizing indexes on every table in the database.
Reorganizing indexes for [dbo].[ASPStateTempApplications]
Reorganizing indexes for [dbo].[tposCompanySettings]
Reorganizing indexes for [dbo].[tpaUnits]
Reorganizing indexes for [dbo].[tpsCrewRecurrence]
Reorganizing indexes for [dbo].[tplIssueTypes]
Reorganizing indexes for [dbo].[tpwLocationGroups]
Msg 1943, Level 16, State 1, Line 1
The index "IDX_tpwLocationGroups_CID" on table "tpwLocationGroups" cannot be reorganized because page level locking is disabled.

Does anyone know how I can modify the script (or a different one) to skip over indexes that cannot do this operation and continue to the next table?

Thanks
Posted
Comments
RedDk 31-Aug-13 15:32pm    
"cannot be reorganized because page level locking is disabled" means (in sys.indexes) [allow_page_locks] is SET to 0. To "enable", SET to 1. Or exclude the ALTER operation using WHERE clause ([allow_page_locks] = 0) on these indexed tables.
onemorecoke 31-Aug-13 16:46pm    
That is perfect! Thank you RedDK. Please put it in the solutions and I will accept.

1 solution

XML
ALTER INDEX < Index name >  ON   < Table Name >
SET (
    ALLOW_PAGE_LOCKS = ON
)
GO


This will work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900