Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

SQLAndy

I'm Andy Warren, currently a SQL Server trainer with End to End Training. Over the past few years I've been a developer, DBA, and IT Director. I was one of the original founders of SQLServerCentral.com and helped grow that community from zero to about 300k members before deciding to move on to other ventures.

Blobs and Filestreams

In the next week or so I’ll be upgrading the SQL 2005 server that has the SQLSaturday database and I’m looking forward to giving the filestream a workout. For those of you new to the issue for years we’ve had the choice of either storing files in the file system and a pointer (filename) in the database, or storing the actual file in the database. The generally accepted decision point was to store in the db if under 1 meg, otherwise in the filesystem. Of course, it’s all one or the the other per column, so you have to decide in the beginning. It’s always been hotly debated, but I’ve been in favor of storing in the db because:

  • I can back them up with the db
  • I can apply SQL security to them
  • They are part of transactions
  • Easy to replicate to other servers

But I also get that that doesn’t fit for all scenarios. Filestreams are new in SQL 2008 and are an attribute of varbinary(max) columns that let you store the file in the file system, but it looks like it’s stored in the table – an interesting hybrid. Right now we store the files associated with each SQLSaturday presentation as a single zip file in the db, so this will be a good exercise in migrating them out to disk as I convert that to filestream. Migration sucks no matter which way, but it strikes me as less painful for those that went with in the database rather than pointers – when I’m doing all the queries will still work and no changes required to procedures or code. I’ll have to write some code to test the streaming option to see if that would also be change free, but at rough glance it seemed like it was more than that. Good to experiment and learn some lessons on a real project, though admittedly a small one!

Comments

Posted by Anonymous on 15 September 2009

Pingback from  Dew Drop – September 15, 2009 | Alvin Ashcraft's Morning Dew

Posted by hugh t on 15 September 2009

Andy, I look forward to reading about your impressions. We are considering Filestream for a new development project, but even better to see how well an existing solution converts.

Posted by Bryan Smith on 15 September 2009

We have a database with over 11TB of files stored in the DB. I'm working on a plan to migrate them to filestream as well. I've already migrated us to 2008, I chose not to do both 2005 to 2008 and move to filstream at once. Instead I chose to seperate the migrations out over time to lower the complexity and risk.

Posted by Andy Warren on 15 September 2009

Hugh, I'll let you know, should be interesting.

Bryan, nothing wrong with lowering risk - that's way up on the list of things to manage in our business, cool features or not!

Posted by grajamurali on 25 September 2009

Hi, while using FileStream, the docs and images were stored in a folder called 'documents'. If any of the file is deleted physically from the location, then the select query returns an error 'inconsistency error occured'. Is there is any way to overcome this?

Thanks.

Leave a Comment

Please register or log in to leave a comment.