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 10: Integrating <strong>FILESTREAM</strong> with other <strong>SQL</strong> <strong>Server</strong> Featuresname is between parentheses). Check the value in the Status column. If it is blank, thenthe service is stopped. Right-click the service name and select Start. If you want theservice to start automatically when Windows starts, modify the Properties <strong>of</strong> the serviceand change the Startup type to Automatic.Once CDC is enabled, we can make some data modifications and see the results in thecaptured tables (Listing 10-21).-- Update the content <strong>of</strong> the ItemImage columnUPDATE ItemsSET ItemImage = CAST(1 AS VARBINARY(MAX))-- Delete the recordDELETE FROM ItemsListing 10-21: Updating the <strong>FILESTREAM</strong> value to generate some CDC log entries.Now, let's go to the CDC tables and see whether the data has been captured(Listing 10-22).DECLARE@LSNFrom BINARY(10) = sys.fn_cdc_map_time_to_lsn('smallest greater than or equal',GETDATE() - 1) ,@LSNTo BINARY(10) = sys.fn_cdc_map_time_to_lsn('largest less than or equal',GETDATE())SELECT CASE [__$operation]WHEN 1 THEN 'Delete'WHEN 2 THEN 'Insert'WHEN 3 THEN 'Update (Old Values)'WHEN 4 THEN 'Update (New Values)'END AS Operation ,ItemNumber ,ItemDescription ,DATALENGTH(ItemImage) AS ImageSizeFROM cdc.fn_cdc_get_all_changes_dbo_Items(@LSNFrom, @LSNTo,'all update old') ;380

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

Saved successfully!

Ooh no, something went wrong!