martes, 9 de agosto de 2011

Error al reorganizar índices en plan de mantenimiento

En el log del trabajo podemos encontrar algo así como el siguiente error:

Failed:(-1073548784) Executing the query "ALTER INDEX [PK_XXXX] ON [dbo].[XXXXX] REOR..." failed with the following error: "The index "PK_XXXX" (partition 1) on table "XXXXX" cannot be reorganized because page level locking is disabled.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.


La causa es que la opción de "Page Locks", requerida para efectuar la reorganización o la recreación de índices, ha sido deshabilitada. Al parecer esto suele ocurrir cuando se migra una bbdd de SQL 2005 al 2008; por alguna razón  en algunos índices se deshabilita esta opción.



Puede arreglarse:

>ALTER INDEX [PK_XXXX ON [dbo].[XXXXXX] SET (

ALLOW_PAGE_LOCKS = ON

) ;

Con Management Studio,  botón derecho en el índice en cuestión, propiedades, opciones y ahí marcáis la opci´´on de permitir  "page lock"