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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2: Getting Started with <strong>FILESTREAM</strong>-- Change the <strong>FILESTREAM</strong> filegroupALTER TABLE Items SET(<strong>FILESTREAM</strong>_ON = NorthPole_fs2)-- Add the <strong>FILESTREAM</strong> column backALTER TABLE ItemsADD [ItemImage] VARBINARY(MAX) <strong>FILESTREAM</strong> NULLListing 2-28:Changing the <strong>FILESTREAM</strong> filegroup <strong>of</strong> a table.Disabling <strong>FILESTREAM</strong> Storage on a DatabaseDisabling <strong>FILESTREAM</strong> storage on a database involves removing the <strong>FILESTREAM</strong>files and filegroups from the database. This can be done by using an ALTER DATABASEstatement.If the database contains any tables that use <strong>FILESTREAM</strong> storage, all references tothe <strong>FILESTREAM</strong> filegroups must be removed before the <strong>FILESTREAM</strong> filegroups areremoved. <strong>The</strong> procedure is summarized below.1. Drop all <strong>FILESTREAM</strong> columns from all tables using ALTER TABLE.2. Set the <strong>FILESTREAM</strong>_ON attribute on all the tables to NULL using ALTER TABLE.3. Remove the <strong>FILESTREAM</strong> file using ALTER DATABASE.4. Remove the <strong>FILESTREAM</strong> filegroup using ALTER DATABASE.Assume that the NorthPole database has a table with a <strong>FILESTREAM</strong> column, createdusing Listing 2-7. <strong>SQL</strong> <strong>Server</strong> will not allow the <strong>FILESTREAM</strong> filegroup to be removeduntil all the other steps have been made.86

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

Saved successfully!

Ooh no, something went wrong!