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 Administration<strong>The</strong> following sections examine a few common causes <strong>of</strong> a corrupt <strong>FILESTREAM</strong>database, and how to use DBCC CHECKDB or DBCC CHECKTABLE to check the consistency<strong>of</strong> your database along with the <strong>FILESTREAM</strong> data, and try to fix any corruption issues.Corruption caused by missing <strong>FILESTREAM</strong> datafiles<strong>The</strong> recommended way to delete a <strong>FILESTREAM</strong> data file is by setting the value <strong>of</strong> thecolumn to NULL by performing a T-<strong>SQL</strong> UPDATE operation. If a user or s<strong>of</strong>tware processdirectly deletes a file from the <strong>FILESTREAM</strong> data container, you will end up with acorrupted database. Let's replicate this scenario here (we're about to deliberately corrupt adatabase, so only do this on a test database on a test server).Run the script in Listing 7-11 to create a new <strong>FILESTREAM</strong>-enabled database with a<strong>FILESTREAM</strong> column and two rows.USE masterGOIF DB_ID('NorthPole') IS NOT NULLDROP DATABASE NorthPoleGOCREATE DATABASE NorthPole ON PRIMARY (NAME = NorthPole,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter7\NorthPole.mdf'), FILEGROUP NorthPole_fs CONTAINS <strong>FILESTREAM</strong>(NAME = NorthPole_fs,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter7\NorthPole_fs') LOG ON (NAME = NorthPole_log,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter7\NorthPole_log.ldf')GOUSE NorthPoleGO285

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

Saved successfully!

Ooh no, something went wrong!