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 8: Backup and Restore for <strong>FILESTREAM</strong> DatabasesCreating and Populating the Sample DatabaseAs usual, our preparatory step for the examples is to re-create our NorthPole database,the Items table, with the <strong>FILESTREAM</strong> column, and populate it with some fresh data.We've performed this step many times now so, without further ado, the script is inListing 8-1. <strong>The</strong> only additional point to note is that, immediately after creating thedatabase, we ALTER it to stipulate use <strong>of</strong> the FULL recovery model because we wishto perform transaction log backups for this database. It is not possible to performtransaction log backups for a database operating in SIMPLE recovery model.<strong>The</strong> script below starts with dropping the database if it already exists. In case you intendto repeatedly execute this script and subsequent exercises provided below, as part <strong>of</strong> yourtests/experiment, you might want to consider dropping the database from SSMS. Whenyou drop a database from SSMS, it will also remove the backup history from the MSDBdatabase, resulting in a cleaner environment for the new database.USE masterGO-- If the database already exists, drop and re-create itIF DB_ID('NorthPole') IS NOT NULL BEGINDROP DATABASE NorthPoleENDGO-- Create a <strong>FILESTREAM</strong>-enabled databaseCREATE DATABASE NorthPole ONPRIMARY (NAME = NorthPole,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\NorthPole.mdf'), FILEGROUP NorthPole_fs CONTAINS <strong>FILESTREAM</strong>(NAME = NorthPole_fs,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\NorthPole_fs')LOG ON (NAME = NorthPole_log,FILENAME = 'C:\<strong>Art</strong>OfFS\Demos\Chapter8\NorthPole_log.ldf')GO313

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

Saved successfully!

Ooh no, something went wrong!