How to Create a database with support for FILESTREAM

Source: Internet
Author: User
Tags sql server management sql server management studio

This topic describes how to create a database that supports FILESTREAM. Because FILESTREAM uses a special type of file group, you must specify the contains filestream clause for at least one file group when creating a database.

Create a database with FILESTREAM Enabled
1. in SQL Server Management Studio, click "new query" to display the query editor.
2. Copy the following example of Transact-SQL code to the query editor. This Transact-SQL code can create a database with FILESTREAM enabled, called Archive.
Note: For this script, the C: \ Data DIRECTORY must exist.
3. to generate a database, click execute ".

Example
The following code example creates a database named Archive. The database contains three file groups: PRIMARY, Arch1, and filestreamgroup1. PRIMARY and Arch1 are regular file groups that cannot contain FILESTREAM data. FileStreamGroup1 is a FILESTREAM file group.
SQL
Copy codeThe Code is as follows:
Create database Archive
ON
PRIMARY (NAME = Arch1,
FILENAME = 'C: \ data \ archdat1.mdf '),
FILEGROUP FileStreamGroup1 contains filestream (NAME = Arch3,
FILENAME = 'C: \ data \ filestream1 ')
Log on (NAME = Archlog1,
FILENAME = 'C: \ data \ archlog1.ldf ')
GO

For FILESTREAM file groups, FILENAME references a path. The path of the last folder must exist, but the last folder cannot exist. In this example, c: \ data must exist. However, when executing the create database statement, the filestream1 sub-Folder cannot exist. For more information about this syntax, see create database (Transact-SQL ).

After running the preceding example, the filestream. hdr file and the $ FSLOG folder will appear in the c: \ Data \ filestream1 folder. The filestream. hdr file is the header file of the FILESTREAM container.

Important
Filestream. hdr files are important system files. It contains the FILESTREAM header information. Do not delete or modify this file.
For existing databases, you can use the alter database statement to add FILESTREAM file groups.

Related Article

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.