Database Reference
In-Depth Information
How to do it...
Once the prerequisites for FILESTREAM and Collation are completed, complete the following
steps to design a storage solution for unstructured data and new collations. Initially, we will
create a solution for unstructured data:
1. Let us create a new database by associating a file group with a specific path and also
designate the name of the folder that was created during the SQL Server installation
on the file system.
USE master
GO
CREATE DATABASE EntzStreaming ON PRIMARY
( NAME = N'EntzStreaming',
FILENAME = N'd:\entz\FS\data\EntzStreaming.mdf',
SIZE = 4048KB , FILEGROWTH = 1024KB ),
FILEGROUP FS_EStreaming CONTAINS FILESTREAM
(NAME = 'FG_EntzStreaming',
FILENAME = N'd:\entz\FS\DBIASSQA')
LOG ON
( NAME = N'PhotoRepository_log',
FILENAME = N'd:\entz\FS\log\EntzStreaming_log.ldf',
SIZE = 1024KB , FILEGROWTH = 10%)
GO
2.
The database is created along with the FILESTREAM folder to share the name as
DBIASSQA .
3.
We will use the dbo.MuzikStore table to store a music file, which is classified as
unstructured data.
USE EntzStreaming
GO
CREATE TABLE dbo.MuzikStore
(MuzikID uniqueidentifier ROWGUIDCOL NOT NULL PRIMARY KEY,
MuzikName varchar(50) NOT NULL,
MuzikFile varbinary(max) FILESTREAM)
GO
4.
Now that we have created a database and table to store the data, let us insert
the data using the regular INSERT statement and import file using the
OPENROWSET command.
INSERT dbo.MuzikStore
(MuzikID, MuzikName, MuzikFile) SELECT NEWID(),
'The Last Waltz - Dreaming and Relaxing', BulkColumn FROM
OPENROWSET(BULK
'D:\ENTZ\FS\DBIASSQA\The Last Waltz.mp3', SINGLE_BLOB) AS Muzik
 
Search WWH ::




Custom Search