1

I am working with creating a FileTable in sql server 2012. I want to store the files on a SAN (Storage Area Network). I have mapped it to a drive on sql server.

To use the FileTable, I need to set up a file system group. I am using the following script but failing to get it correct:

ALTER DATABASE [MyDatabase]
ADD FILE 
(
    NAME = FileStreamFile,
    FILENAME= '\\123.456.789.001\MyFolder',
    MAXSIZE = UNLIMITED
    )
TO FileGroup MyFileStreamGroup
END

The entry I have for the FileName always seems to fail. How can I set up a FileStreamGroup to point at SAN and which in turn I will use to create a file table from it?

4

2 回答 2

1

正如您所发现的,您不能使用 UNC 路径将文件流文件放到远程驱动器上。最好的办法是在 SAN 上创建一个 LUN 并通过 iSCSI 连接到该 LUN,这样驱动器将显示为 SQL Server 的本地驱动器,但物理上仍位于 SAN 上。

您可能想与您的存储管理员讨论如何真正做到这一点。

于 2013-05-20T09:52:22.003 回答
0

首先,您需要创建一个文件组:

ALTER DATABASE [MyDatabase]
ADD FILEGROUP [MyFileStreamGroup]

然后您可以向其中添加文件:

ALTER DATABASE [MyDatabase]
ADD FILE ( 
    NAME = N'NewDataFile'
    ,FILENAME = N'\\123.456.789.001\MyFolder\NewDataFile.mdf' 
    ,SIZE = 1024KB
    ,FILEGROWTH = 1024KB
) TO FILEGROUP [MyFileStreamGroup]

最后你可以创建表:

CREATE TABLE [MyDatabase].[dbo].[NewTable] (
    [Id] int NOT NULL,
    [Text] varchar(50) NOT NULL
) ON [MyFileStreamGroup]

通过指定ON [MyFileStreamGroup]强制它在该文件组中创建,这反过来将使用 SAN 上新创建的文件。如果您不指定 filegrop,则该表将以默认值结束,通常称为 PRIMARY。如果您希望新文件组为默认值,您可以使用:

ALTER DATABASE [MyDatabase]
MODIFY FILEGROUP [MyFileStreamGroup] DEFAULT
于 2013-05-18T18:11:03.803 回答