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> Databasessys.all_columns, sys.columns and sys.system_columns<strong>The</strong> sys.all_columns view contains the columns belonging to all the user-definedobjects and system objects in the current database.<strong>The</strong> sys.columns view is essentially a subset <strong>of</strong> sys.all_columns and containsthe columns belonging to all the table valued assembly functions, inline table valuedfunctions, internal tables, system tables, table valued functions, user tables and views,again, in the current database.Both views contain the is_filestream column, which returns 1 for <strong>FILESTREAM</strong>columns, and so can be used to determine all the <strong>FILESTREAM</strong> columns in the currentdatabase, as shown in Listing 9-1.SELECTs.name AS SchemaName,t.name AS TableName,c.name AS ColumnNameFROM SYS.columns cINNER JOIN sys.tables t ON t.object_id = c.object_idINNER JOIN sys.schemas s ON s.schema_id = t.schema_idWHERE is_filestream = 1/*SchemaName TableName ColumnName---------- --------- ----------dbo Items ItemImage*/Listing 9-1:Retrieving all the <strong>FILESTREAM</strong> columns from the current database.This sys.sytem_columns view contains a row for every column in all systemobjects and also has an is_filestream column which is expected to return 1 for all<strong>FILESTREAM</strong> columns. However, since none <strong>of</strong> the system tables in the <strong>SQL</strong> <strong>Server</strong>versions up to and including 2012 have <strong>FILESTREAM</strong> columns, this column will alwayscontain 0. It is possible that a future version <strong>of</strong> <strong>SQL</strong> <strong>Server</strong> may have system tables with<strong>FILESTREAM</strong> columns.330

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

Saved successfully!

Ooh no, something went wrong!