码迷,mamicode.com
首页 > 其他好文 > 详细

excel 数据导入数据表

时间:2015-12-16 15:23:29      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

环境:

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:\Website\MacauStore\Data\AllData_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 NMicrosoft.ACE.OLEDB.12.0, NAllowInProcess, 1
    GO
    EXEC master.dbo.sp_MSset_oledb_prop NMicrosoft.ACE.OLEDB.12.0, NDynamicParameters, 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

excel 数据导入数据表

标签:

原文地址:http://www.cnblogs.com/xiaobuild/p/5050981.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!