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>refore, the recommended method for creating tables with <strong>FILESTREAM</strong> columnsis to write the CREATE TABLE statements using T-<strong>SQL</strong> (as described in the followingsection). Alternatively, you can do this in a two-step process: create all columns exceptthe <strong>FILESTREAM</strong> columns using the table designer, and then use T-<strong>SQL</strong> ALTER TABLEstatements to create the <strong>FILESTREAM</strong> column (see Using T-<strong>SQL</strong> to add <strong>FILESTREAM</strong>columns to an existing table, later in this chapter).Using T-<strong>SQL</strong> to create a table with <strong>FILESTREAM</strong>columns<strong>The</strong> script in Listing 2-7 creates a table with a <strong>FILESTREAM</strong> column. <strong>The</strong> <strong>FILESTREAM</strong>column is created by adding the <strong>FILESTREAM</strong> attribute to the VARBINARY(MAX) columncalled ItemImage. Only VARBINARY(MAX) columns can be used for <strong>FILESTREAM</strong>storage.CREATE TABLE [dbo].[Items]([ItemID] UNIQUEIDENTIFIER ROWGUIDCOLNOT NULLUNIQUE ,[ItemNumber] VARCHAR(20) ,[ItemDescription] VARCHAR(50) ,[ItemImage] VARBINARY(MAX) <strong>FILESTREAM</strong>NULL)Listing 2-7:Creating a table with a <strong>FILESTREAM</strong> column.Notice that <strong>FILESTREAM</strong> is not a data type; it is an attribute that you can set on aVARBINARY(MAX) column. Setting this attribute adds <strong>FILESTREAM</strong> storage capabilitiesto the column.61

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

Saved successfully!

Ooh no, something went wrong!