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 11: FileTableAs a best practice, consider writing code that is independent from the <strong>SQL</strong> <strong>Server</strong>configuration by using relative paths. If you are storing path values anywhere, store thevalue relative to the database-level directory. That way, a change to the configuration <strong>of</strong><strong>SQL</strong> <strong>Server</strong> will not break the application.You may be storing path values as part <strong>of</strong> an application's configuration data, whichmight allow the application to retrieve the folder where all order files are located. Toavoid storing the full path: \\servername\MS<strong>SQL</strong>SERVER\NorthPole\Documents\Order Files store instead: \Order Files. <strong>The</strong>n, when the full path is needed, call theFileTableRootPath() function and concatenate your stored value to the return value<strong>of</strong> the function.A more comprehensive discussion <strong>of</strong> the use <strong>of</strong> .NET file I/O APIs is beyond the scope <strong>of</strong>this book. However, below are some limitations that exist in the use <strong>of</strong> the APIs.• It's not possible to rename the database or FileTable root directories usingthe I/O APIs.• It's not possible to obtain an exclusive handle on the database or FileTableroot directories.Managing FileTablesIn addition to the functions and views that apply to all <strong>FILESTREAM</strong>-enabled databasesand tables, there are specific functions and views added to <strong>SQL</strong> <strong>Server</strong> 2012 to support theFileTable feature.T-<strong>SQL</strong> functionsIn addition to the PathName() function, which has existed since <strong>SQL</strong> <strong>Server</strong> 2008,three new documented T-<strong>SQL</strong> functions have been added to <strong>SQL</strong> <strong>Server</strong> 2012:FileTableRootPath(), GetFileNamespacePath() and GetPathLocator().423

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

Saved successfully!

Ooh no, something went wrong!