天天看点

FILESTREAM data cannot be placed on an empty filegroup 解决办法

如果你也遇到了filestream data cannot be placed on an empty filegroup 这个错误。

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部分

FILESTREAM data cannot be placed on an empty filegroup 解决办法
FILESTREAM data cannot be placed on an empty filegroup 解决办法

语法

 1 alter database database_name 

 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 data cannot be placed on an empty filegroup 解决办法

 你看了这个语法,再看前面给出来的答案你就会明白那样子的添加文件并没有和库的filestream有任何的关联。所以应该是这样的:

alter database [你的数据库]

add file(name= 文件逻辑名,

filename = 文件全名) to filegroup 你的filestream名

也就是以上的例子需要在后面加上to filegroup来指明文件添加到哪个filestream下。

到这里基本的上主要的问题就都解决掉了。

剩下的按照最初的解决方一一对照修正就可以解决了。

欢迎加群互相学习,共同进步。qq群:ios: 58099570 | android: 330987132 | go:217696290 | python:336880185 | 做人要厚道,转载请注明出处!http://www.cnblogs.com/sunshine-anycall/archive/2010/07/10/1774948.html