Reindex all databases and Raiserror

  • I am trying to reindex all databases with the help of SQL job with a stored procedure. The issue is that the reindex fails if log of any database becomes full in between. I have used raiserror to capture it... Is there a way the job skips if the log full database and continues to the next one? The logic I am using is as follows:

    Select the databases to reindex

    While all databases are not reindexed

    Begin Try

    SP_ReIndexDB

    End Try

    Begin Catch

    Raiserror ('Error found',0,1)

    End Catch

    Select Next database to reindex.

    The above logic just logs an error in the output file specified in the job about the Tlog full error but does not continue to next database.

    -- Ravinder Pal

  • Piling on, Michele's scripts are excellent. I'd absolutely support putting those in place on any production system I supported.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply