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 Applications-- Create a VIEWCREATE VIEW ItemInfo ASSELECT ItemNumber, ItemImage FROM ItemsGO-- SELECT from the VIEWSELECTItemNumber,ItemImage.PathName()FROM ItemInfo/*-- OutputMsg 5539, Level 16, State 1, Line 3<strong>The</strong> ROWGUIDCOL column associated with the <strong>FILESTREAM</strong> being used is not visiblewhere method PathName is called.*/Listing 3-30:Using a view to show that the ROWGUIDCOL must be visible to the PathName() query.<strong>The</strong> ItemInfo view does not include the ROWGUIDCOL column, so a call to thePathName() on any <strong>of</strong> the columns will generate an error. To fix this problem, we mustinclude the ItemID column (which is marked as ROWGUIDCOL) in the view, as shown inListing 3-31.ALTER VIEW ItemInfo ASSELECTItemNumber,ItemImage,ItemID --This is needed for PathName()FROM ItemsListing 3-31:Adding the ROWGUIDCOL column to the view.Similarly, the query on the CTE in Listing 3-32 will fail because the ROWGUIDCOL is notvisible to the PathName() function.121

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

Saved successfully!

Ooh no, something went wrong!