Enable the Prerequisites for FileTable
Describes how to enable the prerequisites for creating and using FileTables.
I want to …
To enable the prerequisites for creating and using FileTables, enable the following items:
At the instance level:
At the database level:
FileTables extend the capabilities of the FILESTREAM feature of SQL Server. Therefore you have to enable FILESTREAM for file I/O access at the Windows level and on the instance of SQL Server before you can create and use FileTables.
For information about how to enable FILESTREAM, see Enable and Configure FILESTREAM.
When you call sp_configure to enable FILESTREAM at the instance level, you have to set the filestream_access_level option to 2. For more information, see filestream access level Server Configuration Option.
Before you can create FileTables in a database, the database must have a FILESTREAM filegroup. For more information about this prerequisite, see Create a FILESTREAM-Enabled Database.
FileTables let Windows applications obtain a Windows file handle to FILESTREAM data without requiring a transaction. To allow this non-transactional access to files stored in SQL Server, you have to specify the desired level of non-transactional access at the database level for each database that will contain FileTables.
The available levels of non-transactional access are FULL, READ_ONLY, and OFF.
- Specify the level of non-transactional access by using Transact-SQL
- Specify the level of non-transactional access by using SQL Server Management Studio
You can specify the level of non-transactional access in the FILESTREAM Non-transacted Access field of the Options page of the Database Properties dialog box. For more information about this dialog box, see Database Properties (Options Page).
When you enable non-transactional access to files at the database level, you can optionally provide a directory name at the same time by using the DIRECTORY_NAME option. If you do not provide a directory name when you enable non-transactional access, then you have to provide it later before you can create FileTables in the database.
In the FileTable folder hierarchy, this database-level directory becomes the child of the share name specified for FILESTREAM at the instance level, and the parent of the FileTables created in the database. For more information, see Work with Directories and Paths in FileTables.
The name that you specify must be unique across the instance for database-level directories.
- Specify a directory for FileTables by using Transact-SQL
When you create a new database, call the CREATE DATABASE (SQL Server Transact-SQL) statement with the DIRECTORY_NAME FILESTREAM option.
When you alter an existing database, call the ALTER DATABASE (Transact-SQL) statement with the DIRECTORY_NAME FILESTREAM option. When you use these options to change the directory name, the database must be exclusively locked, with no open file handles.
When you attach a database, call the CREATE DATABASE (SQL Server Transact-SQL) statement with the FOR ATTACH option and with the DIRECTORY_NAME FILESTREAM option.
When you restore a database, call the RESTORE (Transact-SQL) statement with the DIRECTORY_NAME FILESTREAM option.
- Specify a directory for FileTables by using SQL Server Management Studio
You can specify a directory name in the FILESTREAM Directory Name field of the Options page of the Database Properties dialog box. For more information about this dialog box, see Database Properties (Options Page).
Setting the DIRECTORY_NAME is optional when you call CREATE DATABASE or ALTER DATABASE. If you do not specify a value for DIRECTORY_NAME, then the directory name remains null. However you cannot create FileTables in the database until you specify a value for DIRECTORY_NAME at the database level.
The directory name that you provide must comply with the requirements of the file system for a valid directory name.
When the database contains FileTables, you cannot set the DIRECTORY_NAME back to a null value.
When you attach or restore a database, the operation fails if the new database has a value for DIRECTORY_NAME that already exists in the target instance. Specify a unique value for DIRECTORY_NAME when you call CREATE DATABASE FOR ATTACH or RESTORE DATABASE.
When you upgrade an existing database to SQL Server 2016, the value of DIRECTORY_NAME is null.
When you enable or disable non-transactional access at the database level, the operation does not check whether the directory name has been specified or whether it is unique.
When you drop a database that was enabled for FileTables, the database-level directory and all the directory stuctures of all the FileTables under it are removed.