Home Forums SQL Server 2005 Administering "..table "ItemNum" cannot be reorganized because page level locking is disabled" RE: "..table "ItemNum" cannot be reorganized because page level locking is disabled"

  • :)This is a good solution

    SET NOCOUNT ON

    DECLARE @DBName nvarchar(50), @INName nvarchar(50)

    DECLARE @ODBName nvarchar(50), @OINName nvarchar(50)

    Declare @execstr nvarchar(200)

    --PRINT '-------- Vendor Products Report --------'

    DECLARE Index_cursor CURSOR FOR

    Select A.Name as InName,ob.Name as DBName from sys.indexes A

    left outer join sys.objects ob on ob.object_id=A.Object_id

    where allow_page_locks=0 and ob.type='U'

    -- Select only allow_page_locks 0 and User Tables

    OPEN Index_cursor

    FETCH NEXT FROM Index_cursor

    INTO @INName, @DBName

    WHILE @@FETCH_STATUS = 0

    BEGIN

    PRINT @DBName +' ' + @INName

    --PRINT @INName

    SET @ODBName = ltrim(rtrim(@DBName))

    SET @OINName = ltrim(rtrim(@INName))

    SELECT @execstr = 'ALTER INDEX '+@OINName+ ' ON '+

    @ODBName+' SET (ALLOW_PAGE_LOCKS = ON)';

    EXEC (@execstr);

    FETCH NEXT FROM Index_cursor

    INTO @INName, @DBName

    END

    CLOSE Index_cursor

    DEALLOCATE Index_cursor

    Cheers,

    Ranjith:)

    Ranjith Lekamalage
    MCITP SQL 2012 (BI Development)