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 9: Investigating <strong>FILESTREAM</strong> DatabasesIdentifying the tables with <strong>FILESTREAM</strong> columnsA <strong>FILESTREAM</strong> column can be identified by looking at the is_filestream column <strong>of</strong>the system view sys.columns, as shown in Listing 9-9.SELECT DISTINCTOBJECT_NAME(OBJECT_ID) AS TableNameFROM sys.columns cWHERE c.is_filestream = 1/*TableName---------ItemsItems2Items3Items4*/Listing 9-9:Retrieving a list <strong>of</strong> all tables with <strong>FILESTREAM</strong> fields in a database.Identifying the <strong>FILESTREAM</strong> folder names associated witheach <strong>FILESTREAM</strong> table<strong>SQL</strong> <strong>Server</strong> creates a root folder for every <strong>FILESTREAM</strong> table in the database. Since thefolders are named using GUID values, it will <strong>of</strong>ten be very confusing when you haveseveral <strong>FILESTREAM</strong> tables in the database. Listing 9-10 shows a query that can be usedto determine the folder names associated with each <strong>FILESTREAM</strong> table.SELECTt.name AS TableName,d.name AS FileGroup,p.filestream_guid AS FolderNameFROM sys.tables tINNER JOIN sys.system_internals_partitions pON p.object_id = t.object_id341

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

Saved successfully!

Ooh no, something went wrong!