MS Sql 2008 - Add a FileStream column to an existing table (alter)
I couldn’t find any straight answer after googling, so I’m gonna put it here for all of you who want to add a FileStream varbinary to an existing table.
You should already know that you can not do this from the design window of your table.
You need to do it in 3 steps:
First one is defining in which filegroup the files need to be stored. You define your filegroup on database level.
ALTER TABLE dbo.YourTable SET (FILESTREAM_ON = FileStreamGroup)
Next you create a row guid column
ALTER TABLE dbo.YourTable ALTER COLUMN GuidFieldAsPK ADD ROWGUIDCOL
Finally you add the file
ALTER TABLE dbo.YourTable ADD YourNewFileStreamField varbinary(max) FILESTREAM NOT NULL
I found the code here: http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/13de4291-f48e-438c-bee5-40d80746fc7b