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 ApplicationsFROM ItemsFor each row in the result setFor column 1 to 3Open the <strong>FILESTREAM</strong> data fileRead from <strong>FILESTREAM</strong> data FileDo something with the dataClose the <strong>FILESTREAM</strong> data fileNext columnNext rowCommit transactionClose database connection*/Listing 3-25:Pseudocode that shows how to read BLOB data from more than one row and column.Understanding the Logical Path to a<strong>FILESTREAM</strong> Data FileYou may have noticed by now that <strong>FILESTREAM</strong> deals with a lot <strong>of</strong> logical identifiers! Forexample, the <strong>FILESTREAM</strong> file share, configured while enabling the <strong>FILESTREAM</strong> feature(see Appendix A) is not mapped to a physical directory on the system; it is simply a logicalidentifier that <strong>SQL</strong> <strong>Server</strong> uses internally to point to the <strong>FILESTREAM</strong> data container. Ifyou try to explore the <strong>FILESTREAM</strong> share name by double-clicking on it from WindowsExplorer, you will realize that it does not open any folder, as would be expected for a"normal" file share.Just like the <strong>FILESTREAM</strong> file share, the logical path to a <strong>FILESTREAM</strong> data file (returnedby the PathName() function) is an internal identifier that <strong>SQL</strong> <strong>Server</strong> uses to point tothe disk file associated with a <strong>FILESTREAM</strong> data value. When a client application wantsto read or write <strong>FILESTREAM</strong> data through the streaming APIs, it needs to have a wayto exactly pinpoint the <strong>FILESTREAM</strong> value on a specific table, row, or column. <strong>The</strong>PathName() function make this simpler. A client application can run a T-<strong>SQL</strong> query thatlocates the specific <strong>FILESTREAM</strong> value and calls the PathName() function to retrieve alogical identifier pointing to it.115

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

Saved successfully!

Ooh no, something went wrong!