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 AdministrationAs you can see, <strong>SQL</strong> <strong>Server</strong> cannot fix an inconsistency error <strong>of</strong> this type. If it findsa foreign file in the <strong>FILESTREAM</strong> data container, it will return an error, butDBCC CHECKTABLE or DBCC CHECKDB will not remove the unwanted file. You mustremove it yourself to fix the corruption.Corruption can leak into your backup filesNote that, if you take a backup <strong>of</strong> the database, the backup will also include the orphaned file. If yousubsequently restore the backup, the new database will be corrupted as well.Before moving on, delete the orphaned file from the <strong>FILESTREAM</strong> data container,then run DBCC CHECKDB again, to make sure that the database is no longer in acorrupted state.Corruption caused by deleting the garbage filesmanuallyAs discussed earlier in the Garbage files and recovery models section, there is sometimes adelay before garbage files are deleted. If you lose patience and delete garbage files yourself,you may create a problem for the garbage collector, as it will try to remove files that nolonger exist.If you have been following through with the example over the previous sections, theItems table in NorthPole database has only one record. Go to the <strong>FILESTREAM</strong> datacontainer and note down the name <strong>of</strong> the file. Next, run the script in Listing 7-17 toupdate the <strong>FILESTREAM</strong> data value. <strong>The</strong> update operation will generate a new file withthe modified value and the old file will become garbage.292

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

Saved successfully!

Ooh no, something went wrong!