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. 数据库:ubantu下MySQL安装指南

    http://wiki.ubuntu.org.cn/MySQL%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97 安装MySQL sudo apt-get install mys ...

  2. Android 4学习(6):概述 - 深入了解Android Activity

    参考:<Professional Android 4 Application Development> 深入了解Android Activity 每一个Android Activity都对 ...

  3. 部署和调优 2.9 mysql主从配置-3

    测试 先给主mysql解锁 > unlock tables; 删除一个表 > use db1; > show tables; > drop table help_categor ...

  4. struts2学习笔记(1)配置与基本操作

    主要作用:将请求与页面区分开 配 置: 下载struts 2.0,在安装路径D:\项目学习\三大框架视屏\struts-2.3.24-all\struts-2.3.24\apps 中解压struts2 ...

  5. Android getWidth和getMeasuredWidth的区别

    getWidth 得到的事某个View的实际尺寸. getMeasuredWidth 得到的是某个View想要在parent view里面占的大小 相比你也见过这样的解释,听起来这样的解释也是云里雾里 ...

  6. koa2 原生链接mysql

    1.安装mysql $ npm install mysql 2.代码示例: const mysql = require("mysql"); // mysql.Promise = g ...

  7. PCL —— RCNN Family 中层次点云处理

    博客转载自:http://www.cnblogs.com/ironstark/p/6046411.html RCNN是从图像中检测物体位置的方法,严格来讲不属于三维计算机视觉.但是这种方法却又非常非常 ...

  8. Linux 性能调优

    一.简介 有些时候,我们特别关注程序的性能,特别是底层软件,比如驱动程序,OS等.为了更好的优化程序性能,我们必须找到性能瓶颈点,"好钢用在刀刃上"才能取得好的效果,否则可能白做工 ...

  9. java中的全局变量与静态变量的区别与联系?有时候为什么专门定义静态变量。(标题党~~)

    static代表“每个类一个”而不是“每个对象一个”.即静态变量是类的所有对象共有的. 1 static JFrame f; static MyDrawPanel ml; 整个应用程序如下: 定义在p ...

  10. Luogu 3704 [SDOI2017]数字表格

    列一下式子: $\prod_{i = 1}^{n}\prod_{j = 1}^{m}fib_{gcd(i, j)}$ 很套路的变成这样: $\prod_{d = 1}^{min(n, m)}fib_{ ...