zoukankan      html  css  js  c++  java
  • 关于使用EXCEL数据源通过:Openrowset 或 Opendatasource导入SQL批量更新数据

    1.配置Openrowset或Opendatasource为可用

    注意:如果是64位SQL请安装 AccessDatabaseEngine_X64  

              如果是32位SQL请安装 AccessDatabaseEngine   否测会报错

    --变更显示高级配置
    sp_configure 'show advanced options', 1;
    RECONFIGURE;
    GO
    --重新配置为可导入
    sp_configure 'Ad Hoc Distributed Queries', 1;
    RECONFIGURE;

     --允许在进程中使用ACE.OLEDB.12
        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
    --使用openrowset导入excel
    select * into DataImportable from OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;DATABASE=D:Excelimport.xls',[sheet0$])
    --使用Opendatasource导入excel
    select * into DataImportable1 from OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source=D:Excelimport.xls;Extended Properties=Excel 12.0')...[Sheet0$];

    select * from dataimportable
    select * from dataimportable1
    --通过连接更新表 实例
    update A set A.mjbh=b.模具编号,a.cpmc=b.产品名称    
    slect a.mjbh,b.模具编号,a.cpmc,b.产品名称
    select a.mjbh,b.模具编号,a.cpmc,b.产品名称 from formtable_main_44 A,dataimportable B where a.djbh=b.单据编号

  • 相关阅读:
    初涉Django与MySQL连接
    Mysql数据库操作常用命令
    解决远程登录MYSQL数据库
    全集网影片下载
    LR学习资料
    LR性能测试说明
    fiddler
    Axure(快速原型设计工具)
    httpwatch
    Appscan(安全性测试工具)
  • 原文地址:https://www.cnblogs.com/ccnlc/p/14442686.html
Copyright © 2011-2022 走看看