t-sql read xlsx
2013-07-09 10:29
127 查看
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:
If the Excel 2007 or Excel 2010 file does not contain any headers, simply add the “HDR=No” to the OPENROWSET command as follows:
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:
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:
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/
相关文章推荐
- Read an Excel xlsx with PL/SQL
- java poi read write xlsx
- mysql驱动错误:java.sql.SQLException: Unknown system variable 'tx_read_only'
- Authority setting for sql server activity monitor read permissions
- WINCE 写SQLiet的时候提示Attempt to write a read-only database
- pandas使用read_sql遇到的编码问题('latin-1' codec can't encode characters in position 12-15: ordinal not in r)
- [Oracle] 利用Uniread 解决 Linux下的SQL*Plus 命令行历史回调功能
- 【R语言】R读取含中文excel文件,read.xlsx乱码问题
- SqlDataReader的关闭问题,报错:“阅读器关闭时尝试调用 Read 无效”
- Windows Phone 7.5 - Local SQL Database:How to read the DB schema in windows phone 7
- Read SQL Table into C# DataTable
- SQL error: attempt to write a readonly database
- 利用Uniread 解决 Linux下的SQL*Plus 命令行历史回调功能
- java.sql.SQLException: Io 异常: Got minus one from a read call
- R转换.csv文件格式到.txt或.xlsx) [read.csv and export data to .txt or .xlsx]
- java code to read xls and xlsx files
- SparkSQL read Elasticsearch ClassNotFoundException
- SQL Server Database:Read-Only
- pandas read_sql与read_sql_table、read_sql_query 的区别
- 当SqlDataReader.Read()少一条记录时