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: FileTableIn Listing 11-15, the constraint checks that either the value <strong>of</strong> the is_directory columnis 1 (we'll allow creating folders at any level) or that the level in the hierarchy is greaterthan 1. This will prevent users from creating files at the FileTable's root, but not at anyother level. When attempting to create a new file at the root, the error message shown inFigure 11-5 will appear.Figure 11-5:Error message when attempting to create a file at Level 1 after applying a constraint.If you have plans to apply the same constraint to multiple FileTables in the database, itwould be a good idea to extract the logical expression into a user-defined function. Fornow, however, let's remove this constraint from the table (Listing 11-16).ALTER TABLE DocumentsDROP CONSTRAINT CK__Documents__NoFilesInRootListing 11-16: Drop a user-defined constraint from a FileTable.Restrictions on creating FileTablesWhile most operations that can be performed on regular tables can be performed onFileTables, there are a few restrictions. Foremost, <strong>of</strong> course, is the notion that the schemais predefined and fixed. You cannot add or remove columns from a FileTable. Usually, it'spossible to work around that limitation by defining another table and creating a one-toonerelationship between the FileTable and the table containing the additional data.410

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

Saved successfully!

Ooh no, something went wrong!