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 7: <strong>FILESTREAM</strong> Database AdministrationALTER DATABASE NorthPoleADD FILEGROUP NorthPole_fs2CONTAINS <strong>FILESTREAM</strong>Listing 7-21:Adding a new <strong>FILESTREAM</strong> filegroup.Next, associate the filegroup with the location to which we want to move the<strong>FILESTREAM</strong> data (Listing 7-22).ALTER DATABASE NorthPoleADD FILE(NAME= NorthPole_fs2,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter7\NorthPole_fs2')TO FILEGROUP NorthPole_fs2Listing 7-22:Adding a file to the newly created <strong>FILESTREAM</strong> filegroup.<strong>The</strong> next step is to drop the clustered index (which is also the primary key <strong>of</strong> the table)using the script in Listing 7-23. If there is currently no clustered index on the table, thenmove on to the next step, which is creating a clustered index.ALTER TABLE [dbo].[Items] DROP CONSTRAINT [PKEY_Items]Listing 7-23:Dropping the clustered index on the Items table.Now, in Listing 7-24, we can re-create the clustered index, specifying the location <strong>of</strong> thenew <strong>FILESTREAM</strong> filegroup. <strong>SQL</strong> <strong>Server</strong> will move the <strong>FILESTREAM</strong> data to the newlocation while the clustered index is being built.ALTER TABLE [dbo].[Items]ADD CONSTRAINT [PKEY_Items]PRIMARY KEY CLUSTERED ([ItemID] ASC)<strong>FILESTREAM</strong>_ON [NorthPole_fs2]Listing 7-24:Rebuilding the clustered index to move the <strong>FILESTREAM</strong> data.297

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

Saved successfully!

Ooh no, something went wrong!