How to Read and Load an Excel 2007 or Excel 2010 File Without Using Import/Export Utility

To read an Excel 2007 or Excel 2010 file using OPENROWSET, run the following query:

SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\YourFile.xlsx;',
'SELECT * FROM [Sheet1$]')

If the Excel 2007 or Excel 2010 file does not contain any headers, simply add the “HDR=No” to the OPENROWSET command as follows:

SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\YourFile.xlsx;HDR=No',
'SELECT * FROM [Sheet1$]')

If one of the columns in the Excel 2007 or Excel 2010 file contains a mixed type of data, where some rows may contain just numbers while others may contain alphanumeric values, add the “IMEX=1” to the second parameter of the OPENROWSET command, as follows:

SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\YourFile.xlsx;IMEX=1',
'SELECT * FROM [Sheet1$]')

To load the Excel 2007 or Excel 2010 data to a new SQL Server table, simply add the INTO clause of the SELECT statement as follows:

SELECT *
INTO [dbo].[MyExcelData]
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=C:\YourFile.xlsx;',
'SELECT * FROM [Sheet1$]') we must set adhocremotequeriesenabled = true :
right click the database and choose facets the link is :
http://www.mssqltips.com/sqlservertip/1673/where-is-the-surface-area-configuration-tool-in-sql-server-2008/

t-sql read xlsx的更多相关文章

  1. 一、SQL系列之~使用SQL语言导出数据及实现定时导出数据任务

    一般情况下,SQL数据库中带有导入与导出数据的直接按键操作,点击数据表所在的数据库--任务--导出/导入数据,根据导入/导出向导直接将数据导出即可. 但导出的数据格式多为Excel格式,如果需要导出的 ...

  2. Oracle导出excel

    oracle导出excel(非csv)的方法有两种,1.使用sqlplus  spool,2.使用包体 现将网上相关代码整理后贴出以备不时之需: 使用sqlplus: 使用sqlplus需要两个文件: ...

  3. 64位的Sql Server使用OPENROWSET导入xlsx格式的excel数据的时候报错(转载)

    In the old times while all the CPUs were 32bit, we were happily using JET OLEDB Provider reaching Ex ...

  4. Microsoft SQL Server 17导出xlsx文件时报错:The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. (System.Data)

    导出数据时报错: 如果你是导出office 2007格式 TITLE: SQL Server Import and Export Wizard ---------------------------- ...

  5. SQL Server Reporting Services (SSRS): Reporting Services in SQL Server 2012 (codename "Denali") will support XLSX, DOCX formats. Bye bye 65536 rows limit in XLS files ;)

    当SSRS报表的时候,若相应EXCEL是2003以下,在行数超过65536的时候报表会报错 "Microsoft.ReportingServices.ReportProcessing.Han ...

  6. C#创建Excel(.xls和.xlsx)文件的三种方法

    生成EXCEL文件是经常需要用到的功能,我们利用一些开源库可以很容易实现这个功能. 方法一:利用excellibrary,http://code.google.com/p/excellibrary/ ...

  7. sql server 读取excel里的数据

    以下是执行的sql代码,只拿简单读取数据举例,其他详细的,请自行查看 reconfigure RECONFIGURE GO GO SELECT * FROM OPENROWSET('Microsoft ...

  8. Asp.Net中使用OpenRowSet操作Excel表,导入Sql Server(实例)

    有两种接口可供选择:Microsoft.Jet.OLEDB.4.0(以下简称 Jet 引擎)和Microsoft.ACE.OLEDB.12.0(以下简称 ACE 引擎). Jet 引擎大家都很熟悉,可 ...

  9. 在Excel中使用SQL语句查询和筛选

    本文转自:http://blog.sina.com.cn/s/blog_5fc375650102e1g5.html 今天在微博上看到@数据分析精选 分享的一篇文章,是关于<在Excel中使用SQ ...

  10. sql server sql语句导入数据到execl2007中

    insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:\c.xlsx','select 字段1,字段2 FR ...

随机推荐

  1. 腾讯Web前端开发框架JX(Javascript eXtension tools)

    转自:Web前端开发-Web前端工程师 » 腾讯Web前端开发框架JX(Javascript eXtension tools) JX – Javascript eXtension tools 一个类似 ...

  2. 关于无法解析的外部符号 _main

    今天在写一段代码的时候,遇到了这个问题,一般遇到这种问题,都是找不到主函数,就是main函数,可是我写的代码是有入口地址main函数的呀.最后发现是自己源文件里,main函数是.c文件,.h文件对应的 ...

  3. [更新中]【South使用总结】django开发中使用South进行数据库迁移

    Django开发中使用South进行数据库迁移的使用总结 South的详细资料可产看官方文档http://south.readthedocs.org/en/latest South安装配置 pip i ...

  4. leetcode637

    层次遍历,计算每一层的节点值,然后求平均值. class Solution { public: vector<double> averageOfLevels(TreeNode* root) ...

  5. CentOS6.5安装完没有网络的解决办法

    昨天下了个CentOS 6.5 Minimal 版,在VMware 10下安装好了之后,发现上不了网,PING外网也PING不通. 在网上搜了一下,发现Linux安装好了之后,网卡默认是没有启动的,下 ...

  6. Delphi 询问框 汉化

    Delphi 询问框 汉化 d:\program files (x86)\embarcadero\studio\17.0\source\fmx\FMX.Consts.pas add this file ...

  7. MVC5网站部署到IIS7

    server 2008R2+IIS7.5下配置不会出现什么问题,这里记录下在server2008+IIS7下的配置 参考了一下:http://www.cnblogs.com/fcu3dx/p/3773 ...

  8. Error: Cannot run program "/home/xxx/android_developer_tools/android-ndk-r8/ndk-build.cmd": Unknown reason

    运行OpenCV官方例子  tutorial-2-mixedprocessing 总提示  /home/xxx/android_developer_tools/ 明明在PATH中采用好几种方法都加入了 ...

  9. 使用myeclipse开发Servlet

    1.在myeclipse中创建一个web工程 2.在src目录下建立一个包并建立一个Servlet(myeclipse会自把Servlet映射到web.xml文件中) 3.发布工程,实际上就是把web ...

  10. tortoisesvn 本项目的忽略项

    https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-propertypage.html Adding and Editing Pr ...