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 2: Getting Started with <strong>FILESTREAM</strong><strong>The</strong> script is the same one we would use to create a regular database, except for thefollowing part that creates an additional filegroup to store the <strong>FILESTREAM</strong> data.FILEGROUP NorthPole_fs CONTAINS <strong>FILESTREAM</strong>(NAME = NorthPole_fs,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_fs' )Listing 2-3:Code snippet to show the definition <strong>of</strong> a <strong>FILESTREAM</strong> filegroup.<strong>The</strong> first line in the above listing creates a FILEGROUP named NorthPole_fs. <strong>The</strong>syntax is the same as creating or adding a regular data or log filegroup to a database. <strong>The</strong>clause CONTAINS <strong>FILESTREAM</strong> is new in <strong>SQL</strong> <strong>Server</strong> 2008; it specifies that the filegroupis to be added as a <strong>FILESTREAM</strong> filegroup. <strong>The</strong> next line, NAME = NorthPole_fs,specifies the logical name <strong>of</strong> the filegroup.<strong>The</strong> FILENAME parameter in the third line specifies the file system location to beconfigured as the <strong>FILESTREAM</strong> data container. When creating a new <strong>FILESTREAM</strong>enableddatabase using T-<strong>SQL</strong>, you must provide the complete path to the <strong>FILESTREAM</strong>data container (C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_fs in the above example).<strong>The</strong> parent folder (C:\<strong>Art</strong>OfFS\Demos\Chapter2) must exist at the time <strong>of</strong> executingthe T-<strong>SQL</strong> script; however, the last subfolder in the path (NorthPole_fs) must not exist– if the folder already exists, the T-<strong>SQL</strong> script will fail, as described previously. Remember,you must not tamper with the <strong>FILESTREAM</strong> data container folder. Any change you makedirectly to this folder could corrupt your database.Note also the following, with regard to a <strong>FILESTREAM</strong> filegroup:• it cannot be named PRIMARY• SIZE, MAXSIZE, and FILEGROWTH attributes are inapplicable• it cannot point to a UNC path; it must refer to a path on the local server,a storage area network or an iSCSI target• it can be placed on a compressed disk volume.58

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

Saved successfully!

Ooh no, something went wrong!