Enable FileStream in SQLServer

Source: Internet
Author: User
Tags filegroup
Recently, I have studied how to store big data files in databases. I have seen the FileStream function, which is recorded and used for later use. FileStream is not enabled by default during installation. if you pay attention to it, in the window that selects the database file path, there is a label FileStream. if it is not enabled during installation, you can use the following

Recently, I have studied how to store big data files in databases. I have seen the FileStream function, which is recorded and used for later use. FileStream is not enabled by default during installation. if you pay attention to it, in the window that selects the database file path, there is a label FileStream. if it is not enabled during installation, you can use the following

Recently, I have studied how to store big data files in databases. I have seen the FileStream function, which is recorded for future use.

FileStream is not enabled by default during installation. if you pay attention to it, there is a label "FileStream" in the window that selects the database file path ".

If you have not enabled the FileStream feature during installation, you can enable the FileStream feature using the following settings.

1. open the SQL Server Configuration Manager, find the SQL server service you want to enable under the SQL Server service (the default instance is generally MSSQLServer), right-click the service, select properties, in the Properties window, you can see the FileStream tag and select "enable FILESTREAM for Transact-SQL access"

2. Execute the following command in ssms

EXEC sp_configure filestream_access_level, 2

RECONFIGURE

3. Create a database that supports FileStream,

[SQL]

Create database test

ON

(NAME = test_dat,

FILENAME = 'C: Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATAtestdat. mdf '),

FILEGROUP testGroup1 CONTAINS FILESTREAM

(NAME = testgroup_dat,

FILENAME = 'C: Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATAtestGroup1. ndf ')

LOG ON

(NAME = Sales_log,

FILENAME = 'C: Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATAtestlog. ldf ');

You can also use the following script to add a file group to an existing database to support FileStream.

[SQL]

ALTER database test

Add filegroup FileStreamRecord

CONTAINS FILESTREAM

GO

-- Add a file for storing database photos to FILEGROUP

ALTER database test

ADD FILE

(

NAME = 'filestreamrecord ',

FILENAME = 'd: Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATATestFileStreamRecord. ndf'

)

To filegroup FileStreamRecord

GO

4. Create a data table that can store FileStream

Create table FileStreamRecording

[SQL]

(

ID int,

RowGuidColumn UNIQUEIDENTIFIER

Not null unique rowguidcol,

FILESTREAMColumn varbinary (MAX) FILESTREAM

);

[SQL]

[SQL]

5. Use

[SQL]

Insert into FileStreamRecording VALUES (1, NEWID (), 0x00 );

Insert into FileStreamRecording VALUES (2, NEWID (), 0x00 );

Insert into FileStreamRecording VALUES (3, NEWID (), 0x00 );

GO

SELECT FILESTREAMColumn. PathName () AS 'pathname' FROM FileStreamRecording;

For more information, see online or online help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.