• sqlserver2008 创建支持文件流的数据库


    第一步打开sqlserver数据库filestream特性
    How to: Enable FILESTREAM(12个步骤)

     

    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

    1. On the Start menu, point to All Programs, point to Microsoft SQL Server 2008, point toConfiguration Tools, and then click SQL Server Configuration Manager.

    2. In the list of services, right-click SQL Server Services, and then click Open.

    3. In the SQL Server Configuration Manager snap-in, locate the instance of SQL Server on which you want to enable FILESTREAM.

    4. Right-click the instance, and then click Properties.

    5. In the SQL Server Properties dialog box, click the FILESTREAM tab.

    6. Select the Enable FILESTREAM for Transact-SQL access check box.

    7. 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.

    8. 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.

    9. Click Apply.

    10. In SQL Server Management Studio, click New Query to display the Query Editor.

    11. In Query Editor, enter the following Transact-SQL code:

       
      EXEC sp_configure filestream_access_level, 2
      RECONFIGURE
    12. Click Execute.

       

     第二步 执行创建数据库的sql语句

     

     

     (在执行中可能会遇到 系统拒绝访问的问题,如果没有问题那最好了,解决问题这块就不用看了

          解决此问题请看这里http://connect.microsoft.com/SQLServer/feedback/details/435855/operating-system-error-2147024891-0x80070005-access-is-denied     

          注意他给了不同操作系统的热补丁 ,选择适合自己系统的。

          这个是windows server 2003的 http://support.microsoft.com/kb/973573.

          这个 是 xp的http://support.microsoft.com/?id=978835

    - 创建数据库
    Use Master
    Go
    --数据库文件路径(如果有多级文件夹,需要先手动预先建立才行)。
    --数据库名称:EGDB
    --数据库文件名称:EGDB_Data.mdf
    --数据日志文件名称:EGDB_Data_Log.ldf
    --文件流数据名称:EGDB_FileStreamData
    --文件组名称:EGDB_FileGroup
    --文件流名称: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:dbSQL_EGDBEGDB_HZZ_Data.mdf',
     SIZE = 10MB,
     FILEGROWTH = 10MB),
    FILEGROUP EGDB_HZZ_FileGroup
     ( NAME = EGDBFileStream_Data,
     FILENAME = N'D:dbSQL_EGDBEGDB_Data.ndf',
     SIZE = 10MB,
     FILEGROWTH = 5MB),
    FILEGROUP EGDB_HZZ_FileStream CONTAINS FILESTREAM
     ( NAME = EGDB_HZZ_FileStream,
     FILENAME = N'D:dbSQL_EGDBEGDB_FileStreamData')
    LOG ON
     ( NAME = EGDB_HZZ_Data_Log,
     FILENAME = N'D:dbSQL_EGDBEGDB_Data_Log.ldf',
     SIZE = 5MB,
     MAXSIZE = 500MB,
     FILEGROWTH = 5MB);
    GO

    第三步创建数据表

    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)
    )
     

     

  • 相关阅读:
    kylin_学习_00_资源帖
    Saiku_学习_03_Saiku+Kylin构建多维分析OLAP平台
    Saiku_学习_02_Schema Workbench 开发mdx和模式文件
    Tomcat_总结_02_单机多实例
    Saiku_学习_01_saiku安装与运行
    【HDU】1693 Eat the Trees
    【Ural】1519. Formula 1
    蒟蒻修养之tc蓝名计划
    【UVa】11270 Tiling Dominoes
    【POJ】2406 Power Strings
  • 原文地址:https://www.cnblogs.com/hbhzz/p/3209974.html
Copyright © 2020-2023  润新知