BUG: Rebuilding Indexes w/ SQLMaint May Cause Incorrect Database

Last reviewed: October 29, 1997
Article ID: Q175789
The information in this article applies to:
  • Microsoft SQL Server version 6.5
BUG #: 16955 (WINDOWS: 6.5)

SYMPTOMS

When you attempt to rebuild indexes with the Database Maintenance Wizard (Sqlmaint.exe) or execute DBCC DBREINDEX on at least three tables that have at least one index per table, and then attempt to use sp_dboption to put that database in single user mode, you will get the following error:

   Msg 3508, Level 16, State 1, Server NTJTK1, Line 1
   Attempt to set 'pubs' database to single user mode failed because the
   usage count is 4. Make sure that no other users are currently using this
   database and rerun CHECKPOINT.

CAUSE

When the Database Maintenance Wizard is run directly or as a scheduled task that requests a rebuild of indexes, such as the following, it actually executes a DBCC DBREINDEX for each table in that database:

   sqlmaint -D pubs -RebldIdx 10 -Rpt c:\temp\Pubs_maint.rpt

For an example script, see the MORE INFORMATION section of this article.

WORKAROUND

To work around this problem, put the database in single user mode before running the Database Maintenance Wizard (Sqlmaint.exe). Also, you can clear the usage count by stopping and restarting SQL Server.

STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following SQL script demonstrates the problem:

   use master
   go
   sp_dboption pubs, single, false
   go
   use pubs
   go
   dbcc dbreindex('dbo.authors', null, 0, sorted_data_reorg)
   go
   dbcc dbreindex('dbo.discounts', null, 0)
   go
   dbcc dbreindex('dbo.employee', null, 0, sorted_data_reorg)
   go
   use master
   go
   waitfor delay '00:00:01'
   go
   sp_dboption pubs, single, true
   go


Additional query words: sqlmaint dbreindex
Keywords : kbbug6.50 SSrvGen SSrvSQL_Admin kbusage
Version : WINNT:6.5
Platform : winnt
Issue type : kbbug
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.