Fixing Allocation Errors

If only one table is affected, then use this command:

1> dbcc tablealloc(tablename)
2> go

Otherwise, follow these steps to correct any allocation error that has occurred, including errors 2521, 2540, 2546, and 7940:

  1. Set the database that encountered the error in single-user mode. If the error was on the master database, set it to single-user mode by shutting down and restarting Adaptive Server in single-user mode. Refer to “How to Start Adaptive Server in Single-User Mode” for instructions. If the database is a user database, use this procedure:

    1> sp_dboption database_name, single, true
    2> go
    

    1> use database_name 
    2> go
    

    1> checkpoint
    2> go
    

    Notedbcc checkalloc with the fix option fails with Error 2595 if the database is not set in single-user mode. If you cannot run Adaptive Server with the database in single-user mode, refer to Chapter 3, “Error Message Writeups”for the particular error you are trying to correct, or call Sybase Technical Support.

  2. Run dbcc checkalloc with the fix option to correct the error:

    1> use master 
    2> go
    
    

    1> dbcc checkalloc(database_name, fix)
    2> go
    

  3. Reset the database from single-user mode. To reset the master database, shut down and restart Adaptive Server without the special single-user mode procedure. To reset a user database, use the following procedure:

    1> sp_dboption database_name, single, false
    2> go
    

    1> use database_name 
    2> go
    

    1> checkpoint
    2> go
    

    NoteFor large databases, you may want to execute the commands in steps 1–3 from a script file, which allows you to save the results for future reference.

  4. Examine the dbcc checkalloc output. If there are any errors, refer to Chapter 3, “Error Message Writeups” or contact Sybase Technical Support.