zoukankan      html  css  js  c++  java
  • excel 数据导入数据表

    环境:

    Windows server 2012  rm

    sql server  2012

    excel 数据导入数据表

    INSERT INTO [dbo].[AdminUser]
                
        SELECT [AdminUserID]
               ,[NameZH]
               ,isnull( [NameEng],'') as [NameEng]
               ,[Password]
               ,[CreateDateTime]
               ,[UpdateDateTime]
               ,[RecordTimeStamp] FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 
    'Excel 12.0;Database=C:WebsiteMacauStoreDataAllData_20151216.xls;HDR=YES;IMEX=1',
    'select * from [AdminUser$]')
    View Code

    错误解决:http://stackoverflow.com/questions/13888082/ole-db-provider-microsoft-ace-oledb-12-0-for-linked-server-null-returned-m

    • Open up SQL Server and run the following:

      sp_configure 'show advanced options', 1;
      GO
      RECONFIGURE;
      GO
      sp_configure 'Ad Hoc Distributed Queries', 1;
      GO
      RECONFIGURE;
      GO
      EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
      GO
      EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
      GO
      View Code
    • Now, if you are running OPENROWSET calls you need to abandon calls ,made using the old JET parameters and use the new calls as follows:
      (*Example, importing an EXCEL file directly into SQL):
      DONT DO THIS….
      SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;HDR=YES;Database=c:PATH_TO_YOUR_EXCEL_FILE.xls','select * from [sheet1$]')
      
      USE THIS INSTEAD…
      SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=c:PATH_TO_YOUR_EXCEL_FILE.xls','select * from [sheet1$]')
      
      *At this point resolved two SQL issues and ran perfectly
      View Code
  • 相关阅读:
    调试导论
    CSP-S2 2020 游记
    【题解】51nod 1327 棋盘游戏
    基础数学专题复习
    ubuntu 下 zsh 插件及安装方式
    ubuntu 下 Deepin-TIM 折腾笔记
    微服务学习笔记
    使用 Portainer 管理 Docker 笔记(含本地和远程)
    博客收藏
    定制unittest测试报告【转】
  • 原文地址:https://www.cnblogs.com/xiaobuild/p/5050981.html
Copyright © 2011-2022 走看看