码迷,mamicode.com
首页 > 数据库 > 详细

sql2008_x64 读取excel

时间:2015-05-12 13:14:24      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

sql2008_x64 读取excel

下载64bit 版的AccessDatabaseEngine_x64:http://www.microsoft.com/en-us/download/details.aspx?id=13255

 

 1 --开启导入功能
 2 exec sp_configure show advanced options,1
 3 reconfigure
 4 exec sp_configure Ad Hoc Distributed Queries,1
 5 reconfigure
 6 --允许在进程中使用ACE.OLEDB.12
 7 EXEC master.dbo.sp_MSset_oledb_prop NMicrosoft.ACE.OLEDB.12.0, NAllowInProcess, 1
 8 --允许动态参数
 9 EXEC master.dbo.sp_MSset_oledb_prop NMicrosoft.ACE.OLEDB.12.0, NDynamicParameters, 1
10 
11 --导入临时表 
12  EXEC (SELECT * FROM OPENROWSET(‘‘Microsoft.ACE.OLEDB.12.0‘‘, ‘‘Excel 12.0;Database=D:\AGS-1249.xlsx;DHR=YES‘‘, ‘‘SELECT * FROM [Sheet1$]‘‘))
13 --select * from opendatasource(Microsoft.Ace.OLEDB.12.0,Data Source=D:/AGS-1249.xlsx;Extended properties=Excel 12.0;hdr=yes;IMEX=1)...[sheet1$]
14 --注意这里,要先关闭外围的设置,然后再关闭高级选项
15 exec sp_configureAd Hoc Distributed Queries,0
16 reconfigure
17 exec sp_configureshow advanced options,0
18 reconfigure
19 --关闭ACE.OLEDB.12的选项
20 EXEC master.dbo.sp_MSset_oledb_prop NMicrosoft.ACE.OLEDB.12.0, NAllowInProcess, 0
21 EXEC master.dbo.sp_MSset_oledb_prop NMicrosoft.ACE.OLEDB.12.0, NDynamicParameters, 0

 

sql2008_x64 读取excel

标签:

原文地址:http://www.cnblogs.com/macavalier/p/4496994.html

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