sqlserver2008 创建支持文件流的数据库
?
Before you can start to use FILESTREAM, you must enable FILESTREAM on the instance of the SQL Server Database Engine. This topic describes how to enable FILESTREAM by using SQL Server Configuration Manager.
To enable and change FILESTREAM settings
On the?Start?menu, point to?All Programs, point to?Microsoft SQL Server 2008, point toConfiguration Tools, and then click?SQL Server Configuration Manager.
In the list of services, right-click?SQL Server Services, and then click?Open.
In the?SQL Server Configuration Manager?snap-in, locate the instance of SQL Server?on which you want to enable FILESTREAM.
Right-click the instance, and then click?Properties.
In the?SQL Server Properties?dialog box, click the?FILESTREAM?tab.
Select the?Enable FILESTREAM for Transact-SQL access?check box.
If you want to read and write FILESTREAM data from Windows, click?Enable FILESTREAM for file I/O streaming access. Enter the name of the Windows share in the?Windows Share Name?box.
If remote clients must access the FILESTREAM data that is stored on this share, select?Allow remote clients to have streaming access to FILESTREAM data.
Click?Apply.
In SQL Server Management Studio, click?New Query?to display the Query Editor.
In Query Editor, enter the following Transact-SQL?code:
EXEC sp_configure filestream_access_level, 2 RECONFIGUREClick?Execute.
?
?
?第二步 執(zhí)行創(chuàng)建數(shù)據(jù)庫(kù)的sql語(yǔ)句
?
?
?(在執(zhí)行中可能會(huì)遇到 系統(tǒng)拒絕訪問(wèn)的問(wèn)題,如果沒(méi)有問(wèn)題那最好了,解決問(wèn)題這塊就不用看了
????? 解決此問(wèn)題請(qǐng)看這里http://connect.microsoft.com/SQLServer/feedback/details/435855/operating-system-error-2147024891-0x80070005-access-is-denied?????
????? 注意他給了不同操作系統(tǒng)的熱補(bǔ)丁 ,選擇適合自己系統(tǒng)的。
????? 這個(gè)是windows server 2003的?http://support.microsoft.com/kb/973573.
????? 這個(gè) 是 xp的http://support.microsoft.com/?id=978835)
- 創(chuàng)建數(shù)據(jù)庫(kù)
Use Master
Go
--數(shù)據(jù)庫(kù)文件路徑(如果有多級(jí)文件夾,需要先手動(dòng)預(yù)先建立才行)。
--數(shù)據(jù)庫(kù)名稱(chēng):EGDB
--數(shù)據(jù)庫(kù)文件名稱(chēng):EGDB_Data.mdf
--數(shù)據(jù)日志文件名稱(chēng):EGDB_Data_Log.ldf
--文件流數(shù)據(jù)名稱(chēng):EGDB_FileStreamData
--文件組名稱(chēng):EGDB_FileGroup
--文件流名稱(chēng):EGDB_FileStream
--
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'EGDB_HZZ')
DROP DATABASE EGDB_HZZ
GO
?USE Master
GO
CREATE DATABASE EGDB_HZZ ON PRIMARY
?( NAME = EGDB_HZZ_Data,
?FILENAME = N'D:\db\SQL_EGDB\EGDB_HZZ_Data.mdf',
?SIZE = 10MB,
?FILEGROWTH = 10MB),
FILEGROUP EGDB_HZZ_FileGroup
?( NAME = EGDBFileStream_Data,
?FILENAME = N'D:\db\SQL_EGDB\EGDB_Data.ndf',
?SIZE = 10MB,
?FILEGROWTH = 5MB),
FILEGROUP EGDB_HZZ_FileStream CONTAINS FILESTREAM
?( NAME = EGDB_HZZ_FileStream,
?FILENAME = N'D:\db\SQL_EGDB\EGDB_FileStreamData')
LOG ON
?( NAME = EGDB_HZZ_Data_Log,
?FILENAME = N'D:\db\SQL_EGDB\EGDB_Data_Log.ldf',
?SIZE = 5MB,
?MAXSIZE = 500MB,
?FILEGROWTH = 5MB);
GO
第三步創(chuàng)建數(shù)據(jù)表
use EGDB_HZZ
if exists (select 1
??????????? from? sysobjects
?????????? where? id = object_id('dbo.SYS_FILES')
??????????? and?? type = 'U')
?? drop table dbo.SYS_FILES
go
/*==============================================================*/
/* Table: SYS_FILES???????????????????????????????????????????? */
/*==============================================================*/
create table dbo.SYS_FILES (
?? FILE_ID????????????? uniqueidentifier???? not null default newid(),
?? FILE_NAME??????????? varchar(100)???????? null default ' ',
?? FILE_CONTENT_B?????? varbinary(max)?????? NULL,
?? FILE_CONTENT_C?????? varchar(max)???????? null default ' ',
?? FILE_SIZE??????????? float??????????????? null,
?? FILE_TYPE??????????? varchar(50)????????? null default ' ',
?? FILE_SERVER_PATH???? varchar(200)???????? null default ' ',
?? FILE_REMARK????????? varchar(300)???????? null default ' ',
?? FILE_SYS_TIME??????? datetime???????????? null default getdate(),
?? constraint PK_SYS_FILES primary key (FILE_ID)
)
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/hbhzz/p/3209974.html
總結(jié)
以上是生活随笔為你收集整理的sqlserver2008 创建支持文件流的数据库的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 看科普片随感
- 下一篇: 部署webservice到远程服务器