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>To further understand the <strong>FILESTREAM</strong> filegroup, let's take a look at the minimal T-<strong>SQL</strong>script that creates a <strong>FILESTREAM</strong>-enabled database (Listing 2-1)./*01*/ CREATE DATABASE NorthPole ON/*02*/ PRIMARY (/*03*/ NAME = NorthPole,/*04*/ FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole.mdf'/*05*/ ), FILEGROUP NorthPole_fs CONTAINS <strong>FILESTREAM</strong>(/*06*/ NAME = NorthPole_fs,/*07*/ FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_fs')/*08*/ LOG ON (/*09*/ NAME = NorthPole_log,/*10*/ FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_log.ldf')Listing 2-1:Sample T-<strong>SQL</strong> script to create a <strong>FILESTREAM</strong>-enabled database.Lines 05, 06, and 07 specify the configuration parameters for the <strong>FILESTREAM</strong> filegroup.A closer look will highlight a few differences between a <strong>FILESTREAM</strong> filegroup definitionand the definition <strong>of</strong> a data or log filegroup.First <strong>of</strong> all, the <strong>FILESTREAM</strong> filegroup uses the additional clause CONTAINS<strong>FILESTREAM</strong> which tells <strong>SQL</strong> <strong>Server</strong> to treat the filegroup as a <strong>FILESTREAM</strong> filegroup.This is important, because <strong>SQL</strong> <strong>Server</strong> needs to do some additional work to configure the<strong>FILESTREAM</strong> filegroup.Next, notice the value <strong>of</strong> the FILENAME parameter in line 07; while the FILENAMEparameters <strong>of</strong> data files and log files point to a disk file, for a <strong>FILESTREAM</strong> filegroup itpoints to a folder. <strong>The</strong> <strong>FILESTREAM</strong> data will be stored in multiple files, with one file foreach data value. <strong>The</strong>refore, it makes sense that the <strong>FILESTREAM</strong> filegroup points to afolder, rather than a single file.When you create a <strong>FILESTREAM</strong>-enabled database, <strong>SQL</strong> <strong>Server</strong> will create and configurethe folder specified as the <strong>FILESTREAM</strong> data container. It is very important to ensurethat the leaf-level folder within the path that you provide does not already exist, so that<strong>SQL</strong> <strong>Server</strong> can go ahead and create it. Please also note that <strong>SQL</strong> <strong>Server</strong> will create only51

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

Saved successfully!

Ooh no, something went wrong!