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 3: Accessing <strong>FILESTREAM</strong> Data from Client ApplicationsLet us now try to query the table and see the data we just inserted (Listing 3-28).SELECT * FROM Items/*ItemID Item# ItemDescription ItemImage------------ ------ --------------- -------------------E76D878F-0.. MS1001 Micros<strong>of</strong>t Mouse 0xFFD8FFE000104A4..*/Listing 3-28:Querying the Items table.<strong>The</strong> column ItemImage stores the <strong>FILESTREAM</strong> data we just inserted. To a T-<strong>SQL</strong>query, the <strong>FILESTREAM</strong> column appears as a VARBINARY(MAX) column. However, thedata is stored in the <strong>FILESTREAM</strong> data container as a disk file. Every BLOB value in every<strong>FILESTREAM</strong> column (in every non-NULL <strong>FILESTREAM</strong> field) has a disk file associatedwith it in the <strong>FILESTREAM</strong> data container.<strong>The</strong> logical path name refers to the disk file associated with each BLOB data value,and can be retrieved by using the new intrinsic function PathName(), as shown inListing 3-29. Note that PathName() is case sensitive. You will get an error if thecorrect case is not used when invoking this method.SELECTItemNumber,ItemImage.PathName() AS LogicalPathFROM Items/*Item# LogicalPath------ --------------------------------------------------MS1001 \\localhost\MS<strong>SQL</strong>SERVER\v1\

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

Saved successfully!

Ooh no, something went wrong!