FileTables By Sam Nasr, MCAD, MCT, MCTS NIS October 6, 2012
Housekeeping Forum for learning - Feel free to ask questions Cell Phones on vibrate please Exit stairways at end of hallway Restrooms are near elevators Please fill out surveys (see room monitor) Presentations will be posted on SQL Saturday sight
Introduction Software developer since 1995 Sam Nasr (sam@nasr.info) Software developer since 1995 Independent Software Consultant (Nasr Information Systems) MCAD, MCT, MCTS(WSS/MOSS) President - Cleveland C#/VB.Net User Group President – Cleveland WPF User Group INETA Mentor for Ohio INETA Community Champ Author for Visual Studio Magazine
What is your background? .Net Developer T-Sql Developer DBA Hobbyist/other role
System Requirements (Recommended) 6GB HD min (feature dependant) 4GB RAM min (increased per DB size) 2.0 GHz CPU x86 or x64 Vista, Win 7, Win Server 2008 NTFS recommended (FAT32 supported) .Net 3.5 SP1/4.0 Note: All requirements are version dependant. See MSDN for more installation details.
Demo Environment Intel core Duo CPU 2.40 GHz 4GB RAM 500 GB HD Visual Studio 2010 Ultimate (64-bit) SQL Server 2008/2012 Enterprise (64-bit) Windows 7 Ultimate (64-bit) Note: Windows Server 2008 implemented using “Shrink volume…” Shrink Volume: Control Panel > Administrative Tools > Computer Management > Disk Management; right click C:
What is a FileTable? A table containg meta data on files in a specific directory New table type with predefined schema Utilizes FileStream feature and HierarchyID data type Uses share specified in FileStream
FileTable Contents Every row represents a file or a directory. A FILESTREAM column for stream data and a file_id (GUID) identifier. path_locator and parent_path_locator columns represent file/directory hierarchy. 10 file attributes A type column that supports full-text search and semantic search over files and documents.
Enabling FileStream Machine level During installation SQL Server Config Mgr SQL Server Services | SQL Server (MSSQLSERVER)
Enabling FileStream Server Instance Server Properties | “Advanced” Stored Procedure EXEC sp_configure filestream_access_level, n RECONFIGURE n=0: disabled FileStream completely n=1: enabled for T-SQL access only n=2: enabled for full access (remote file streaming)
Streaming BLOBs OpenSqlFileStream - native client API GET_FILESTREAM_TRANSACTION_CONTEXT Returns a token that represents the current transaction context of a session. UNC Path
Hierarchy ID System Data Type Variable length Enables hierarchal representation of a tree Use ToString() to convert hierarchyid to nvarchar(4000) data type. hierarchyid to XML conversion is not supported.
Hierarchyid Method Reference GetAncestor GetDescendant GetLevel GetRoot IsDescendantOf Parse Read GetReparentedValue ToString Write
Enabling FileTable Enable FILESTREAM at the Instance Level Provide a FILESTREAM Filegroup Enable Non-Transactional Access at the Database Level Specify a Directory for FileTables at the Database Level
Demo FileTables
Conclusion Let’s recap…
Thank you for attending! Contact Info E-mail: sam@nasr.info Blog: http://ClevelandDotNet.blogspot.com Twitter: http://twitter.com/samnasr LinkedIN: http://www.linkedin.com/in/samsnasr SpeakerRate: http://speakerrate.com/samnasr Thank you for attending!