简体   繁体   English

为什么 SSIS 会忽略我从 Excel 源导入的最后一列?

[英]Why is SSIS ignoring the last column of my import from an Excel source?

I'm a business intelligence development intern, so please forgive me if I am not as versed as some in SQL or the Microsoft BI Stack.我是一名商业智能开发实习生,所以如果我不像一些 SQL 或 Microsoft BI Stack 那样精通,请原谅我。

I'm trying to import data from an Excel file (.xls) to an SQL Server database table, and for some reason the connection manager is ignoring the last column of my data entirely.我正在尝试将数据从 Excel 文件 (.xls) 导入 SQL Server 数据库表,但出于某种原因,连接管理器完全忽略了我数据的最后一列。

To make matters stranger, SSIS DOES read the data if I try to set up the connection manager within SSIS while the Excel file is open in Excel.更奇怪的是,如果我在 Excel 文件中打开 Excel 文件时尝试在 SSIS 中设置连接管理器,SSIS 确实会读取数据。 (I think I did this unintentionally at first, and was surprised by the result.) (我想我一开始是无意中这样做的,结果很惊讶。)

Here is a preview of data without the file open in Excel:这是未在 Excel 中打开文件的数据预览:

And a preview of data with the file open before setting up the connection manager in SSIS:以及在 SSIS 中设置连接管理器之前打开文件的数据预览:

Both of these depict the end of the data within the file, but for some reason as you can see, the 'Zone' column is omitted in the first data preview.这两个都描述了文件中数据的结尾,但由于某些原因,如您所见,第一个数据预览中省略了“区域”列。

Steps I've tried so far:到目前为止我尝试过的步骤:

  1. Converting to a .csv file using a script task使用脚本任务转换为 .csv 文件
  2. Using an ADO.Net source and reading the excel data that way使用 ADO.Net 源并以这种方式读取 excel 数据
  3. Using an SQL command to view data rather than select from table or sheet使用 SQL 命令查看数据而不是从表或工作表中选择
  4. Changing the OpenRowset property to specify columns更改 OpenRowset 属性以指定列

Specifics about the source files:关于源文件的细节:

  1. First 3 rows of data are empty (except an image)前 3 行数据为空(图片除外)
  2. Row 4 contains header data第 4 行包含标题数据
  3. 'Zone' column is formatted as general, as is every other column that does not contain a date 'Zone' 列的格式为常规格式,其他不包含日期的列也是如此

If anyone has any ideas or suggestions, I would greatly appreciate the feedback.如果有人有任何想法或建议,我将不胜感激。

Thanks!谢谢!

Sometimes SSIS has trouble detecting the datatype for a given column.有时 SSIS 无法检测给定列的数据类型。 This can lead to unexpected NULLs.这可能会导致意外的 NULL。 Adding IMEX=1 to the ConnectionString can clear this fault.将 IMEX=1 添加到 ConnectionString 可以清除此故障。

Example Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your_Workbook.xls;Extended Properties="EXCEL 8.0;HDR=NO;";示例 Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your_Workbook.xls;Extended Properties="EXCEL 8.0;HDR=NO;";

becomes变成

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your_Workbook.xls;Extended Properties="EXCEL 8.0;HDR=NO; IMEX=1 "; Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your_Workbook.xls;Extended Properties="EXCEL 8.0;HDR=NO; IMEX=1 ";

For more details see this blog post (not my own work):有关更多详细信息,请参阅此博客文章(不是我自己的作品):

http://blog.concentra.co.uk/2013/05/15/why-ssis-always-gets-excel-data-types-wrong-and-how-to-fix-it/ http://blog.concentra.co.uk/2013/05/15/why-ssis-always-gets-excel-data-types-wrong-and-how-to-fix-it/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM