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 AdministrationRun the code in Listing 7-8 to update the <strong>FILESTREAM</strong> columns. <strong>The</strong> first column isupdated to NULL and <strong>SQL</strong> <strong>Server</strong> discards the <strong>FILESTREAM</strong> data file associated withthe field. <strong>The</strong> second column is updated with a new value, and <strong>SQL</strong> <strong>Server</strong> creates a newversion <strong>of</strong> the file containing the new value, and discards the previous file.UPDATE ItemsSET ItemImage1 = NULL ,ItemImage2 = 0x2Listing 7-8:Updating the columns to create garbage files.After the UPDATE operation, you will see three files in the <strong>FILESTREAM</strong> data container.Out <strong>of</strong> the three, two are no longer needed. Those two files will be registered in the<strong>FILESTREAM</strong> tombstone table. We can try to read the names <strong>of</strong> those files from thattable, but first we need to find out its name, as shown in Listing 7-9.SELECTnameFROM sys.internal_tablesWHERE name LIKE '<strong>FILESTREAM</strong>_tomb%'/*name--------------------------------<strong>FILESTREAM</strong>_tombstone_2073058421*/Listing 7-9:Retrieving the name <strong>of</strong> the <strong>FILESTREAM</strong> tombstone table.However, the tombstone table cannot be accessed from the user mode queries. Toread information from this table, we need to connect to the server using DedicatedAdministrator Connection (DAC).282

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

Saved successfully!

Ooh no, something went wrong!