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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: <strong>FILESTREAM</strong> Database AdministrationCorruption caused by orphaned filesCreating or copying unwanted files in the <strong>FILESTREAM</strong> data container can also causecorruption in a database.Let us see what happens when an unwanted file is present in the <strong>FILESTREAM</strong> datacontainer. Go to the <strong>FILESTREAM</strong> data container and create a new file, or copy anexisting file from another folder. For this demonstration, I copied the Micros<strong>of</strong>tMouse.jpg into the <strong>FILESTREAM</strong> data container's folder structure. <strong>The</strong>n, run DBCC CHECKDB orDBCC CHECKTABLE and you should see an error message similar to the following:Table error: <strong>The</strong> file "\12f4b92b-6c51-43a5-9a32-71d1b0de0646\Micros<strong>of</strong>tMouse.jpg" in therowset directory ID 4443b7d5-904c-475d-bcc8-20bc0e09b887 is not a valid <strong>FILESTREAM</strong> file.Note that <strong>SQL</strong> <strong>Server</strong> complains that there is a file present that is not a valid<strong>FILESTREAM</strong> file. One could probably argue that this is because the file is not correctlynamed. Files in the <strong>FILESTREAM</strong> data folder do not have extensions, and they are namedfollowing a certain pattern. Go back to your <strong>FILESTREAM</strong> folder and rename the file sothat it follows the same naming pattern as the other files in the <strong>FILESTREAM</strong> folder, andthen run DBCC CHECKTABLE again.Table error: <strong>The</strong> orphaned file "0000001b-0000015c-0005" was found in the <strong>FILESTREAM</strong> directoryID 12f4b92b-6c51-43a5-9a32-71d1b0de0646 for object ID 21575115, index ID 0, partition ID72057594039042048, column ID 4.Note that the error is different now. This time, <strong>SQL</strong> <strong>Server</strong> detected that there is anorphan file in the <strong>FILESTREAM</strong> directory. Let's see if DBCC CHECKDB can fix this bydeleting the orphaned file; rerun DBCC CHECKDB with repair_allow_data_loss(Listing 7-16).Table error: <strong>The</strong> orphaned file "0000001b-0000015c-0005" was found in the <strong>FILESTREAM</strong> directoryID 12f4b92b-6c51-43a5-9a32-71d1b0de0646 for object ID 21575115, index ID 0, partition ID72057594039042048, column ID 4.291

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

Saved successfully!

Ooh no, something went wrong!