简体   繁体   English

将数据从excel导入sql server

[英]Importing Data from excel into sql server

I am trying to import data into sql server using ssis packages. 我正在尝试使用ssis包将数据导入sql server。 I have a column named description and that has a cell having 690 characters. 我有一个名为description的列,它有一个包含690个字符的单元格。

I am getting a truncation error as SSIS is not able to figure out the maximum length required. 我收到截断错误,因为SSIS无法确定所需的最大长度。 I tried changing the output column properties from the excel source connection but that didn't help. 我尝试从excel源连接更改输出列属性,但这没有帮助。 However, when I move the cell with the maximum length to the first row it works perfectly (as ssis package determines the max length from the first 8 rows). 但是,当我将具有最大长度的单元格移动到第一行时,它完美地工作(因为ssis包确定了前8行的最大长度)。

Since, I want to automate this process I don't want to modify the excel sheet each and every time. 因为,我想自动化这个过程,我不想每次都修改excel表。 I have read about changing the number of rowsets that ssis reads, but haven't been able to figure out how to do it. 我已经阅读过有关更改ssis读取的行集数量的内容,但尚未弄清楚如何执行此操作。

Any type of help would be appreciated. 任何类型的帮助将不胜感激。

The answer to the question is that you go to windows registry and change the excel connection manager to see more than 8 rows to determine the column data type and length, which solves the issue. 问题的答案是你转到Windows注册表并更改excel连接管理器以查看超过8行以确定列数据类型和长度,这解决了问题。

You go to windows registry by typing "regedit" in the run console and when you are in the windows registry you follow 您可以通过在运行控制台中键入“regedit”来访问Windows注册表,当您在Windows注册表中时,您可以关注它

HKEY_LOCAL_MACHINE -> SOFTWARE -> Wow6432Node -> Microsoft -> Jet -> 4.0 ->Engines -> Excel -> and then set the typeguessrows to 0, so that it can parse through the entire file instead of the top 8 rows.

You need to specify the length of your Excel Source input columns. 您需要指定Excel源输入列的长度。

In your SSIS Package, right click on the Excel source in the data flow task and click on "Advance Editor for Excel Source". 在SSIS包中,右键单击数据流任务中的Excel源,然后单击“Excel Source的Advance Editor”。 Next change the data type and length of the column from its default value. 接下来,将列的数据类型和长度从其默认值更改。

If you are using VS2015 or above, right-clic on the Excel Source and clic properties. 如果您使用的是VS2015或更高版本,请在Excel Source和clic属性上使用右键。 In the bottom part of the properties clic in the Show Advance Editor link and change the length in the Input and Output Properties tab. 在“ Show Advance Editor链接中的属性clic的底部,并在“ Input and Output Properties选项卡中更改长度。

Hope it works for you. 希望对你有效。

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

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