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.