17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7: <strong>FILESTREAM</strong> Database AdministrationTo see this working, go back to the <strong>FILESTREAM</strong> data folder and delete the file we justcreated. Run DBCC CHECKTABLE again, and you will see that the error is reported again.Run the script in Listing 7-16 to fix the corruption by deleting the records that havecorrupted <strong>FILESTREAM</strong> values. <strong>The</strong> first action the script performs is to take thedatabase into single user mode. <strong>The</strong> database needs to be in single user mode to performa repair operation.ALTER DATABASE NorthPole SET SINGLE_USERWITH ROLLBACK IMMEDIATEGODBCC CHECKDB('NorthPole', repair_allow_data_loss)/*Msg 7904, Level 16, State 2, Line 2Table error: Cannot find the <strong>FILESTREAM</strong> file "00000015-0000005e-0004"for column ID 4 (column directory ID 4d8cb114-f573-490e-adfa-e4583889b836) inobject ID 2105058535, index ID 0, partition ID 72057594038779904, page ID (1:157),slot ID 0.<strong>The</strong> error has been repaired.Msg 8945, Level 16, State 1, Line 2Table error: Object ID 2105058535, index ID 2 will be rebuilt.<strong>The</strong> error has been repaired.*/Listing 7-16:Fixing <strong>FILESTREAM</strong> corruption by deleting the affected rows.If you run a query on the Items table, you will see that it now has only one row; the rowfrom which the <strong>FILESTREAM</strong> data was missing has been deleted as part <strong>of</strong> the repairprocess. Again, keep in mind that this approach may or may not be acceptable, dependingupon the nature <strong>of</strong> your application and sensitivity <strong>of</strong> the data.290

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!