Search this blog

Saturday, July 2, 2011

Enable FILESTREAM thru command Prompt.

The data which are storing in the table are structured data, because we organizing the data in proper way. but most of the data are unstructured, such as text file, word documents, images, music files, videos, power point slide, etc., mostly these kind of data are stored in different storage area, outside of the system. In this case, database management is very complex, becoz data are scattered in different places instead of in a single place.

Filestream is a new Feature in SQL Server 2008. which allows storage of access to BLOB data using SQL server with NTFS file system. so that Files can be managed by SQL Server. To utilize this new feature, you need to enable FILESTREAM feature on SQL Server 2008. The FILESTREAM feature is disabled during the default SQL Server 2008 installation.

Refer the below link to know about, How to enable FILESTREAM feature manually on SQL Server 2008,
http://blog-mstechnology.blogspot.com/2009/11/enable-filestream-in-sql-server-2008.html.

There are many APIs, utilities and script files are avaialable to enable filestream  in programmatic way.

Following VBScript will help us to enable the filestream thru command prompt.

Download "filestream_enable.vbs" From,
http://sqlsrvengine.codeplex.com/releases/view/14071#DownloadId=36166

Usage
cscript filestream_enable.vbs [/Machine:MachineName] [/Instance:InstanceName] [/Level:level] [/Share:ShareName]

Parameters:
Machine: Target machine name. If not specified, local machine is the default.
Instance: Target instance. If not specified, default instance (MSSQLSERVER) is default.
Level: Level of FILESTREAM functionality to enable, a integer between 0 and 3. If not specified, level 3 is default.

0 - FILESTREAM functionality disabled.
1 - Enable FILESTREAM for T-SQL access.
2 - Enable FILESTREAM for T-SQL and file I/O streaming access but do not allow remote clients file I/O streaming access.
3 - Enable FILESTREAM for T-SQL and file I/O streaming access and allow remote client streaming access.

Share: Name of windows share that is created for file I/O streaming access to FILESTREAM data. If not specified, instance name is default.

Note: To Enable FileStream, you should have administrator access. otherwise you can not enable it.

Example 1:
Open "Command Prompt" with "Run as administrator" then the follow the below steps

set the path of the VBScript file in command prompt.

Enter the "cscript filestream_enable.vbs"

Before Execute the script:-

After Execute the script:-

This will enable FILESTREAM on the local machine for the default instance MSSQLSERVER. The feature will be enabled for T-SQL and file I/O streaming access and the windows share MSSQLSERVER will be created.

Example 2:-
cscript filestream_enable.vbs /Machine:. /Instance:SQLEXPRESS /Level:2 /Share:SQLEXPRESSLOCAL

This will enable FILESTREAM on the local machine for the instance SQLEXPRESS. The feature will be enabled for T-SQL and file/IO streaming access. Remote client file I/O streaming access is disabled. The windows share SQLEXPRESSLOCAL will be created.