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 3: Accessing <strong>FILESTREAM</strong> Data from Client ApplicationsFigure 3-2:Verifying that the copy contains two copies <strong>of</strong> the original text.We can see that the partial update has taken place as expected.Handling multiple <strong>FILESTREAM</strong> columns and rowsOne <strong>of</strong> the interesting features T-<strong>SQL</strong> programming <strong>of</strong>fers is the ability to performset-based operations. A set operation allows you to process more than one row andcolumn in a single T-<strong>SQL</strong> query.However, when it comes to accessing <strong>FILESTREAM</strong> data through the streaming APIs,set-based operations are not applicable. In the examples discussed above, we saw howto read or write a single <strong>FILESTREAM</strong> cell using I/O streaming. If you want to read orwrite more than one <strong>FILESTREAM</strong> column or row, you must process each, one by one.<strong>The</strong> pseudocode in Listing 3-25 shows an approximate representation <strong>of</strong> how to read<strong>FILESTREAM</strong> data from more than one row and column./*Connect to databaseBegin a transactionRetrieve 10 rows from a table that has 3 <strong>FILESTREAM</strong> columnsSELECT TOP 10GET_<strong>FILESTREAM</strong>_TRANSACTION_CONTEXT(),FileStreamColumn1.PathName(),FileStreamColumn2.PathName(),FileStreamColumn3.PathName()114

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

Saved successfully!

Ooh no, something went wrong!