sp_fixindex repairs corrupt indexes on system tables. It can rebuild a specified index or all indexes on the table. sp_fixindex rebuilds the data layer if the target table has a placement or clustered index (it reclaims the unused space in the data layer while working on the placement or clustered index of a system table).
sp_fixindex database_name, table_name [, index_id | null] [, index_name | null] [, force_option]
sp_fixindex pubs2, sysprocedures, 1
sp_fixindex 'testdb', 'sysprocedures', 2
sp_fixindex 'testdb', 'sysprocedures', null, 'csysprocedures'
sp_fixindex 'testdb', 'sysprocedures'
sp_fixindex 'tempdb', 'sysprocedures', 2, null, 1
sp_fixindex 'tempdb', 'sysprocedures', null, 'sysprocedures', 1
sp_fixindex 'tempdb', 'sysprocedures', null, null, 1
Before you run sp_fixindex, make sure your database is in single-user mode, and is reconfigured to allow updates to system tables.
After you run sp_fixindex:
Use the dbcc checktable command to verify that the corrupted index has been fixed
Disallow updates to system tables using sp_configure
Turn off single-user mode
Do not run sp_fixindex on user tables.
Cannot re-create index on this table.
Encyclopedia of Tasks in the Troubleshooting and Error Message Guide.
Indexing for Performance in the Performance and Tuning Guide: Basics.
The permission checks for sp_fixindex differ based on your granular permissions settings.
Setting | Description |
---|---|
Enabled | With granular permissions enabled, you must be the databse owner or a user with own database privilege. |
Disabled | With granular permissions disabled, you must be a user with sa_role. |
Values in event and extrainfo columns from the sysaudits table are:
Information | Values |
---|---|
Event | 38 |
Audit option | exec_procedure |
Command or access audited | Execution of a procedure |
Information in extrainfo |
|