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 AdministrationCREATE TABLE [dbo].[Items]([ItemID] UNIQUEIDENTIFIER ROWGUIDCOLNOT NULLUNIQUE ,[ItemNumber] VARCHAR(20) ,[ItemDescription] VARCHAR(50) ,[ItemImage] VARBINARY(MAX) <strong>FILESTREAM</strong>NULL)GOINSERT INTO Items( ItemID, ItemNumber, ItemDescription, ItemImage )VALUES ( NEWID(), 'MS1001', 'Micros<strong>of</strong>t Mouse', 0x1 ),( NEWID(), 'MS1002', 'Micros<strong>of</strong>t Keyboard', 0x2 )Listing 7-11:Creating a <strong>FILESTREAM</strong> database with a <strong>FILESTREAM</strong> column and two rows.Navigate to the <strong>FILESTREAM</strong> data container using Windows Explorer and you will seethe two <strong>FILESTREAM</strong> data files in the folder associated with the Items table. Go aheadand delete one <strong>of</strong> those files.Let's fire <strong>of</strong>f a few queries to confirm that the database has indeed been corrupted.Listing 7-12 reads data from the Items table.SELECTitemNumber,ItemDescriptionFROM Items/*itemnumberItemDescription-------------------- -------------------MS1001Micros<strong>of</strong>t MouseMS1002Micros<strong>of</strong>t Keyboard*/Listing 7-12:Reading relational data from the corrupted Items table.286

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

Saved successfully!

Ooh no, something went wrong!