zoukankan      html  css  js  c++  java
  • SQL杂俎 —— SQL Server安装备用代码

    OpenRowSet函数能够用于从OLEDB数据源访问远程数据的条件是:

    • 对于指定提供程序(Provider),DisallowAdhocAccess 注册表选项显式设置为0;
    • 启用 Ad Hoc Distributed Queries 高级选项,在SQL Server中,该选项默认是Disable的,需要显式启用(Enable);

    OPENROWSET can be used to access remote data from OLE DB data sources only when the DisallowAdhocAccess registry option is explicitly set to 0 for the specified provider, and the Ad Hoc Distributed Queries advanced configuration option is enabled. When these options are not set, the default behavior does not allow for ad hoc access.

    在SQL Server中启用 “Ad Hoc Distributed Queries” 高级选项的脚本是:

    -- enable
    exec sp_configure 'show advanced options', 1;
    RECONFIGURE;
    exec sp_configure 'Ad Hoc Distributed Queries', 1;
    RECONFIGURE;
    GO
    --disable
    exec sp_configure 'show advanced options', 1;
    RECONFIGURE;
    exec sp_configure 'Ad Hoc Distributed Queries', 0;
    RECONFIGURE;
    GO
    

      

    配置Excel引擎

    在安装Excel处理引擎之后,在SQL Server中,需要配置AllowInProcess 和 DynamicParameters两个选项,否则SQL Server会抛出错误信息:

    “OLE DB provider 'Microsoft.ACE.OLEDB.12.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.”

    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 
    

      

  • 相关阅读:
    C#正则表达式判断输入日期格式是否正确
    Linq 总结
    sql存储过程
    uploadify多文件上传实例--C#
    Get W3WP List when Debugging
    SharePoint 2010 BI:Chart Web Part
    Versioning SharePoint 2010 Workflow In VS
    Multilingual User Interface (MUI) In SharePoint 2013
    Create Custom Modification Form In VS 2012-Part1
    Create Custom Modification Form In VS 2012-Part2
  • 原文地址:https://www.cnblogs.com/MyDoldrums/p/13940440.html
Copyright © 2011-2022 走看看