如果你也遇到了FILESTREAM data cannot be placed on an empty filegroup 这个错误。
你去google搜索,得到的第一条是应该在这里。答案是:
Your script are missing three things:
1) A USE statement for the database.
2) An ALTER DATABASE statement to add a file to the FILESTREAM file group. For instance:
ADD FILE (NAME = filestream_data,
FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\PreviewIntegration_data')
Beware that the file name should be on a single line.
3) A ROWGUIDCOL in the table:
guid uniqueidentifier NOT NULL UNIQUE ROWGUIDCOL,
意思是需要
1. Use [你的数据库名]
2. 修改数据库
完整的应该是这样的(这里只涉及到了修改数据库的file和filegroup部分
2 {
3 < add_or_modify_files >
4 | < add_or_modify_filegroups >
5 }
6 [ ; ]
7
8 < add_or_modify_files > :: =
9 {
10 ADD FILE < filespec > [ ,...n ]
11 [ TO FILEGROUP { filegroup_name } ]
12 | ADD LOG FILE < filespec > [ ,...n ]
13 | REMOVE FILE logical_file_name
14 | MODIFY FILE < filespec >
15 }
16
17 < filespec > :: =
18 (
19 NAME = logical_file_name
20 [ , NEWNAME = new_logical_name ]
21 [ , FILENAME = {'os_file_name' | 'filestream_path' } ]
22 [ , SIZE = size [ KB | MB | GB | TB ] ]
23 [ , MAXSIZE = { max_size [ KB | MB | GB | TB ] | UNLIMITED } ]
24 [ , FILEGROWTH = growth_increment [ KB | MB | GB | TB| % ] ]
25 [ , OFFLINE ]
26 )
27
28 < add_or_modify_filegroups > :: =
29 {
30 | ADD FILEGROUP filegroup_name
31 [ CONTAINS FILESTREAM ]
32 | REMOVE FILEGROUP filegroup_name
33 | MODIFY FILEGROUP filegroup_name
34 { < filegroup_updatability_option >
35 | DEFAULT
36 | NAME = new_filegroup_name
37 }
38 }
39 < filegroup_updatability_option > :: =
40 {
41 { READONLY | READWRITE }
42 | { READ_ONLY | READ_WRITE }
43 }
44
你看了这个语法,再看前面给出来的答案你就会明白那样子的添加文件并没有和库的FileStream有任何的关联。所以应该是这样的:
add FILE (name = 文件逻辑名,
FILENAME = 文件全名) TO FILEGROUP 你的FileStream名
也就是以上的例子需要在后面加上To FileGroup来指明文件添加到哪个FileStream下。
到这里基本的上主要的问题就都解决掉了。
剩下的按照最初的解决方一一对照修正就可以解决了。