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 9: Investigating <strong>FILESTREAM</strong> DatabasesDECLARE @objectID INTSELECT @objectID = OBJECT_ID('Items4')SELECTcp.name AS [ColumnName],p.partition_number AS [Partition],CAST(rs.colguid AS UNIQUEIDENTIFIER) AS [FolderName]FROM sys.sysrscols rsINNER JOIN sys.partitions p ON rs.rsid = p.partition_idAND rs.colguid IS NOT NULLAND p.object_id = @objectIDINNER JOIN sys.syscolpars cp ON cp.colid = rs.rscolidAND cp.id = @objectID/*ColumnName Partition FolderName---------- ----------- ------------------------------------ItemImage1 1BE0F0AE1-03CB-45EA-93E6-AE9CE4C3C875ItemImage2 15F14959C-36A7-4A6F-9BC7-567A9B8CB5DBItemImage3 1A505E6F6-2B34-454B-BF60-A142294349E0ItemImage4 1BB9EE893-0CDB-4849-B0FB-4E0DBCF57864ItemImage5 1D14A7768-8FCC-4B32-B776-89C2CDD8BB1F*/Listing 9-14:Retrieving the <strong>FILESTREAM</strong> folders associated with each <strong>FILESTREAM</strong> column in a table.This query tries to read from a few "internal" tables that are not accessible to regular userqueries. If you copy and paste the above query into your query window and run it, youwill receive the following error:Msg 208, Level 16, State 1, Line 4Invalid object name 'sys.sysrscols'.This happens because the view sys.sysrscols is not accessible to user mode queries.To run queries that are not accessible to user mode queries, you need to make a DAC tothe database. Connecting to <strong>SQL</strong> <strong>Server</strong> using a DAC was discussed in Chapter 7.345

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

Saved successfully!

Ooh no, something went wrong!