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>Now we'll create a partitioned table. <strong>The</strong> script in Listing 2-25 creates a new version <strong>of</strong>the Items table with three partitions. (Remember that the aim <strong>of</strong> this script is to create a<strong>FILESTREAM</strong> table with three partitions for demonstration purposes; the way this table ispartitioned does not make much business sense.)-- Create partition functionCREATE PARTITION FUNCTIONItemPartitionFn (INT)AS RANGE RIGHT FOR VALUES (1, 2) ;-- Create partition scheme for ItemIDCREATE PARTITION SCHEMEItemPartitionSchAS PARTITION ItemPartitionFn ALL TO ([PRIMARY]) ;-- Create partition scheme for <strong>FILESTREAM</strong>CREATE PARTITION SCHEMEItemFSPartitionSchAS PARTITION ItemPartitionFn ALL TO (Northpole_fs) ;-- Create Item table with <strong>FILESTREAM</strong> columnCREATE TABLE Items(ItemGUID UNIQUEIDENTIFIER ROWGUIDCOLNOT NULLUNIQUE ON [PRIMARY] ,ItemID INT ,ItemName VARCHAR(50) ,ItemImage VARBINARY(MAX) <strong>FILESTREAM</strong>)ON ItemPartitionSch(ItemID) <strong>FILESTREAM</strong>_ON ItemFSPartitionSch ;GOListing 2-25:Creating a <strong>FILESTREAM</strong> table with PARTITION.After running the script, if we return to the <strong>FILESTREAM</strong> data container, there are threenew folders; one for each partition in the Items table (Figure 2-8).82

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

Saved successfully!

Ooh no, something went wrong!