SQL Server Rebuild/Reorganize Fragmented Indexes causes CRC error or consistency errors In our test lab I've been experimenting with different jobs to keep our critical indexes from becoming too fragmented. 

I'm currently using the approach described here: sys.dm_db_index_physical_stats (under the Examples -> D section: Using sys.dm_db_index_physical_stats in a script to rebuild or reorganize indexes).  

Basically every hour I query the dm_db_index_physical_stats dynamic management view and if an index is between 5% and 30% fragmented I reorganize it, if it's greater than 30% fragmented I rebuild it. It seems to work fine during most of our testing, however, twice I've run into a problem where the scheduled job fails with an error:


  The operating system returned error 23(Data error (cyclic redundancy
  check).) to SQL Server during a read at offset 0x00000eae3b2000 in
  file 'C:\Program Files\Microsoft SQL
  Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\database.mdf'.
  Additional messages in the SQL Server error log and system event log may provide more detail.
  This is a severe system-level error condition that threatens database integrity and must be corrected immediately.
  Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. [SQLSTATE HY000] (Error 823)


When I run DBCC CHECKDB a problem is reported in one of my indexes, the only way I'm able to fix this problem is by using 

DBCC CHECKDB ('dbname', REPAIR_ALLOW_DATA_LOSS)


I'm not positive, but I suspect this error is caused by rebuilding or reorganizing indexes while my load tests are running in the test lab.

I've searched around and found nobody else reporting this consistency error related to rebuilding indexes. You can see more information about my problem on my blog post: SQL Server Index Corruption: CRC Error &amp; DBCC CHECKDB

Is my approach to tuning indexes flawed? Should I not be trying to rebuild indexes on a "live" database (while traffic is hitting it)? Should I be using SQL Server Enterprise Edition's feature of rebuilding an index with (online=on)? Any help is appreciated.

I'm running SQL Server 2008 R2 Standard.
The operating system returned error 23(Data error (cyclic redundancy check).) to SQL Server during a read


This indicates the operating system detected an issue reading data from the hard disk itself.  When data is written onto the filesystem, the operating system calculates a CRC code for each block written; when that data is subsequently read back the operating system performs the CRC operation again on the read data and compares it with the CRC stored in the filesystem.  If these two CRC codes don't match the OS reports error 23.  I'd be very surprised if there isn't a hardware issue with either the drive itself, or perhaps some other component such as the motherboard or drive controller.  

WITH (ONLINE=ON) in the Enterprise Edition of SQL Server will have no effect whatsoever on this issue.  Online index operations vs offline index operations are no different at the operating system layer; data is read and written as necessary to either rebuild or recreate the index.