Question

I have an existing database and I'd like to take advantage of the FileTable feature in SQL Server 2012. Looking online, this is how I update the database:

ALTER DATABASE MyDB 
ADD FILEGROUP MyDBFiles CONTAINS FILESTREAM
(
    NAME = SomeCoolName,
    FILENAME= 'C:\FileTable\Data'
)
GO

However, I get Incorrect syntax near 'NAME' error.

What am I doing wrong?

Was it helpful?

Solution

You're using the wrong syntax, you need to add the filegroup first, marking it as containing filestream data and then add a file to that filestream filegroup, like this:

ALTER DATABASE MyDB 
ADD FILEGROUP MyDBFiles CONTAINS FILESTREAM
GO
ALTER DATABASE MyDB
ADD FILE
(
    NAME = 'SomeCoolName',
    FILENAME= 'C:\FileTable\Data'
)
TO FILEGROUP MyDBFiles
GO
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top