SSIS 2008 Excel 源 - 加载字母数字列时出现问题
我正在使用 SSIS 2008
从 Excel
加载字母数字
列。
我有一列从整数开始,
1
2
...
999
然后更改为 AlphaNumeric
A1
A2
A999
当我尝试使用 Excel 数据源
进行加载时,Excel 总是会说它是一个 整数
,因为它必须仅对文件的顶部进行采样。
(顺便说一句 - 我知道我可以重新排序文件,以便阿尔法位于顶部,但我宁愿不必这样做......)
不幸的是,您似乎无法改变主意。这意味着当它加载数据时,它会过滤掉 'A'
并且 A999
记录将更新 999 记录。这显然不太好... 我尝试在高级编辑选项
下将外部列和输出列更改为字符串,但出现错误,并且在将列设置回整数之前它不会运行。
有人有解决办法吗?
I am using SSIS 2008
to load alphanumeric
columns from Excel
.
I have one column which starts off as integer
1
2
...
999
Then changes to AlphaNumeric
A1
A2
A999
When I try to load using using an Excel Data Source
, excel will always say that it is an integer
as it must only sample the top of the file.
(BTW - I know that I can re-order the file so that the alphas are at the top but I would rather not have to do this...)
Unfortunately you can't seem to be able to change its mind. This means that when it loads the data, it filters out the 'A'
and the A999
record will update the 999 record. This is obviously not good...
I have tried to change the external and output columns to string under the advanced editing options
, but I get errors and it won't run until you set the columns back to integer.
Does anyone have a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SSIS 使用
Jet
访问Excel
文件。默认情况下,Jet 会扫描数据的前 8 行
以确定每列的类型。要修复此问题,您需要编辑
注册表
以增加以下注册表项之一的TypeGuessRows DWORD
值,以确定要扫描数据的行数:取决于 Windows 版本和 excel 版本...如下所示:
然后,在连接字符串中指定
IMEX=1
,如下所示:可以在以下位置找到更详细的信息:< a href="http://support.microsoft.com/kb/189897/" rel="nofollow">http://support.microsoft.com/kb/189897/
SSIS uses
Jet
to access theExcel
files. By default, Jet scans thefirst 8 rows
of your data to determine the type of each column.To fix it, you will need to edit the
registry
to increase theTypeGuessRows DWORD
value of one of the following registry keys to determine how many rows to scan in your data:It depends on what version of Windows and what version of excel ... as follows:
Then, specify
IMEX=1
in the connection string as follows:This information can be found in a more verbose form at: http://support.microsoft.com/kb/189897/
哇,这看起来真是一个巨大的痛苦。我遇到了几个示例,您可以更改连接字符串,有时会获得更好的结果,但它们似乎并不适合所有人。
编写自动转换为 .csv 文件的脚本将是一个很好的解决方法,此线程中有许多建议:
在没有 GUI 的情况下将 Excel (xls) 文件转换为逗号分隔 (csv) 文件
包括您使用的一些 C# 代码也许能够轻松进入:
http://jarloo.com/code /api-code/excel-to-csv/
这是一个类似的问题,如果您想自己研究一下,则讨论更改连接字符串:SSIS Excel 导入强制不正确的列类型
祝你好运!
Wow, that looks like a huge pain. I came across a couple of examples where you could alter the connection string and sometimes get better results but they don't seem to work for everyone.
Scripting an automatic conversion to an .csv file would be a good workaround, there are a number of suggestions in this thread:
converting an Excel (xls) file to a comma separated (csv) file without the GUI
including some code in C# that you may be able to easily plop in:
http://jarloo.com/code/api-code/excel-to-csv/
here is the simiar question where altering the connection string is discussed if you want to look into it for yourself: SSIS Excel Import Forcing Incorrect Column Type
Good luck!