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>CREATE DATABASE NorthPole ON PRIMARY (NAME = NorthPole,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole.mdf'), FILEGROUP NorthPole_fs1 CONTAINS <strong>FILESTREAM</strong> DEFAULT(NAME = NorthPole_fs1,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_fs1'), FILEGROUP NorthPole_fs2 CONTAINS <strong>FILESTREAM</strong>(NAME = NorthPole_fs2,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_fs2') LOG ON (NAME = NorthPole_log,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter2\NorthPole_log.ldf')GOListing 2-26:Creating a database with two <strong>FILESTREAM</strong> filegroups.Note that, if you have more than one <strong>FILESTREAM</strong> filegroup, you need to specifyone <strong>of</strong> them as the default filegroup; <strong>SQL</strong> <strong>Server</strong> will use the default filegroup for the<strong>FILESTREAM</strong> storage if you create a table without specifying the <strong>FILESTREAM</strong> filegroup.In Listing 2-29, NorthPole_fs1 is specified as the default.To specify the <strong>FILESTREAM</strong> filegroup for the table you are creating, use the<strong>FILESTREAM</strong>_ON clause, as shown in Listing 2-27, in which two tables are created, eachusing a different filegroup.-- Store <strong>FILESTREAM</strong> data on "NorthPole_fs1"CREATE TABLE [dbo].[Items1]([ItemID] UNIQUEIDENTIFIER ROWGUIDCOLNOT NULLUNIQUE ,[ItemNumber] VARCHAR(20) ,[ItemDescription] VARCHAR(50) ,[ItemImage] VARBINARY(MAX) <strong>FILESTREAM</strong>NULL) <strong>FILESTREAM</strong>_ON NorthPole_fs1GO84

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

Saved successfully!

Ooh no, something went wrong!