Posted by: vincenzotenisci | November 26, 2008

SQL 2008 FILESTREAM and Sharepoint Document Libraries…. why not?

When I first read about sql server 2008 filestream I don’t know why (or I know ;) )
but my mind started to think about WSS/MOSS 2007 so why don’t try to use this new feature
for document libraries storage?
 
Before start, if you want to know all the detail about FILESTREAM read FILESTREAM Storage in SQL Server 2008
from MSDN site where you can find all the information you need.
 
OK let’s start:
 
First of all (if you didn’t enable FILESTREAM during SQL Server 2008 installation),
you have to perform these steps to enable FILESTREAM support to your SQL Server instance:
  1. Open SQL Server Configuration Manager (Start-All Programs-SQL Server 2008-Configuration Tools).
  2. Select SQL Services on the left, right click on SQL Server instance you are interested on and click properties
  3. Select FILESTREAM tab. In this tab you have three options (I Choose all three options):
    • Enable FILESTREAM for Transact SQL Access: you can perform TSQL SELECT, INSERT UPDATE and DELETE operations
    • Enable FILESTREAM for file I/O Streaming access: you can access FILESTREAM data using WIN32 API
    • Allow remote client to have streaming access to FILESTREAM data: you can store/access data on/from a remote file share
  4. Open SQL Server Management Studio and configure SQL Server to support FILESTREAM using this script:
       
        EXEC sp_configure filestream_access_level, 2;
        GO
        RECONFIGURE;
        GO
  5. At this point open Sharepoint central administration, create a new Application with a content Database name (for exampe: WSS_Content_Filestream) and create a site collection for testing (I create a blank site).
  6. Now you have to crate a FILESTRAM Filegroup for the new content database:
    • Go to management studio, right click on the new content database and select properties
    • Select Filegroups and create a new Filestream Filegrop name (for example FILESTORAGE)
  7. Open SQL Server management studio and run this script:
      
      ALTER DATABASE WSS_Content_Filestream
      ADD FILE(
       NAME=FSGroupFile1,
       FILENAME=’c:\MyDBData\FSDATA’
      )
      TO FILEGROUP FILESTORAGE;
      GO
      Note: use your WSS content database name. Replace FILENAME value with your directory name. Replace the name FILESTORAGE with your Filegroup name.
      If all runs well you can go under your directory (c:\MyDBData\FSDATA) and notice the presence of filestream.hdr file for metadata and the
      $FSLOG directory for FILESTREAM database transaction log.
  8. With management studio, open your WSS_Content database, expand Tables folder and right click the dbo.AllDocStreams table and generate
    the two scripts in new query windows for drop and create table (Script Table As – Drop And Create To – New Query Windows).
    If you go to the CREATE TABLE part, you will notice that dbo.AllDocStreams table has a column called Content of type image.
    For filestream usage, you have to use the varbinary(max) data type. You have also to add a new column to the table of type
    uniqueidentifier of type rowguidcol unique, not null and with default value of NewId() (I called this column DocumentId).
    So you have to change the CREATE TABLE part for the Content column from this:

      [Content] image NULL
        To this:
      [Content] varbinary(max) FILESTREAM NULL,
      [DocumentId] UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL UNIQUE DEFAULT NEWID()

          You also have to specify the FILESTREAM filegroup for that table:
          locate the ON [PRIMARY] instruction at the end of the CREATE TABLE and replace with this instruction:
  
          ON [PRIMARY] FILESTREAM_ON FILESTORAGE (NOTE FILESTORAGE is my FILESTREAM Filegroup name).

 

Et voilà, if you go to your filestream directory (c:\MyDBData\FSDATA) you will notice the presence of a new directory and a subdirectory.
One is created for the table and the other is created for the filestream column.

Now you can go yo your site collection, create a new document library, upload some documents,
go to the filestream directory on the file system and you will see your document files stored outside SQL Server!
 
Hope this helps
Vincenzo


Responses

  1. nice article on Filestream great read

  2. Hi,Great blog with interesting informations. I can use it t solve my problem.ThanxM.http://www.vanjobb.hu/

  3. Great Blog! Thanks for the information. We are thinking of using this option for a document center site that may contain about 50GB of data. Do you know or have experienced any problems using Filestreaming? Also, I\’ve heard the current version of MOSS2007 will not support filestreaming. Any of that true?

  4. HiThank you for your valuable information. I installed SQL server 2008 with filestream enabled and also Moss 2007. Without enabling Filestream for content DB for web application, we can save large files in any document library with above 100 MB. But with enabling filestrem only files with max. 5 MB could be uploaded in document library. Can you please help me to find what is wrong here?

  5. Hi to all!First of all thank you for you interest in the article and sorry for the response delay! :) Second: remember that this solution is NOT supported by MS because you cannot alterate the Sharepoint DB Structure by hand. I expect that this functionality will be supported in SP 2010.Third: As you can read from the article mentioned above (FILESTREAM Storage in SQL Server 2008) you can reach great performance if you use the native Win32 api for streaming data and SP uses Transact-SQL access.Fourth: ANVAR, for the 5GB problem… is very strange, I don\’t think that is a SQL Server problem, it resemble to an HTTP/Web server upload problem, check this post and see if it solves the problem ;) http://support.microsoft.com/kb/925083Vincenzo

  6. http://www.batteryfast.com/hp/nc6120.htm hp nc6120 battery http://www.batteryfast.com/dell/inspiron-1100-series.htm dell inspiron 1100 series battery http://www.batteryfast.com/dell/inspiron-1150.htm dell inspiron 1150 battery http://www.batteryfast.com/dell/inspiron-5150.htm dell inspiron 5150 battery http://www.batteryfast.com/dell/inspiron-5160.htm dell inspiron 5160 battery http://www.batteryfast.com/dell/inspiron-5100.htm dell inspiron 5100 battery http://www.batteryfast.com/dell/latitude-131l.htm dell latitude 131l battery http://www.batteryfast.com/dell/vostro-1000.htm dell vostro 1000 battery http://www.batteryfast.com/dell/gd761.htm dell gd761 battery http://www.batteryfast.com/dell/nt379.htm dell nt379 battery http://www.batteryfast.com/dell/latitude-d531.htm dell latitude d531 battery http://www.batteryfast.com/dell/precision-m65.htm dell precision m65 battery http://www.batteryfast.com/dell/vostro-1700.htm dell vostro 1700 battery http://www.batteryfast.com/gateway/8msb.htm gateway 8msb battery http://www.batteryfast.com/hp/pb992a.htm hp pb992a battery http://www.batteryfast.com/hp/dv2100.htm hp dv2100 battery http://www.batteryfast.com/hp/dv2200.htm hp dv2200 battery http://www.batteryfast.com/hp/hstnn-c29c.htm hp hstnn-c29c battery http://www.batteryfast.com/hp/nc8000.htm hp nc8000 battery http://www.batteryfast.com/dell/inspiron-b120.htm dell inspiron b120 battery http://www.batteryfast.com/dell/inspiron-b130.htm dell inspiron b130 battery http://www.batteryfast.com/gateway/12msbg.htm gateway 12msbg battery http://www.batteryfast.com/hp/7400.htm hp 7400 battery http://www.batteryfast.com/dell/inspiron-b120.htm dell inspiron b120 battery http://www.batteryfast.com/toshiba/pa3356u.htm toshiba pa3356u battery http://www.batteryfast.com/hp/2510p.htm hp 2510p battery http://www.batteryfast.com/hp/f3172a.htm hp f3172a battery http://www.batteryfast.com/dell/inspiron-2200.htm dell inspiron 2200 battery http://www.batteryfast.com/gateway/squ-414.htm gateway squ-414 battery http://www.batteryfast.com/hp/hstnn-lb33.htm hp hstnn-lb33 battery http://www.batteryfast.com/mitac/bp-8089.htm mitac bp-8089 battery http://www.batteryfast.com/toshiba/satellite-m55.htm toshiba satellite m55 battery http://www.batteryfast.com/toshiba/satellite-m115.htm toshiba satellite m115 battery http://www.batteryfast.com/toshiba/qosmio-f25.htm toshiba qosmio f25 battery http://www.batteryfast.com/toshiba/satellite-m60.htm toshiba satellite m60 battery http://www.batteryfast.com/toshiba/satellite-p200.htm toshiba satellite p200 battery http://www.batteryfast.com/toshiba/pa3536u-1brs.htm toshiba pa3536u-1brs battery http://www.batteryfast.com/hp/hstnn-db17.htm hp hstnn-db17 battery

  7. A word of caution to all of you out there in cyberspace : this approach completely changes the data type of the underlying column from image to varbinary. The type change will break some T-SQL functions used by system WSS/MOSS procedures. For example, the txtptr function is used in the proc that finalizes the upload of a document, and it does not accept parameters of type varbinary.

  8. http://mycooldesigner.com/ed-hardy-women-hoody-c-15.html ed Hardy Women Hoodyhttp://mycooldesigner.com/gd-tshirts-c-37.html G&D T-Shirtshttp://mycooldesigner.com/gd-tshirts-c-37.html G-d T-Shirthttp://mycooldesigner.com/gd-tshirts-c-37.html Gd T-Shirts cheap


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.