将Excel导入SS2000; 字段错误; 数字传输系统
我正在尝试使用 DTS 将 Excel 文件导入到 SQL Server 2000 数据库中。 这没什么花哨的,只是直接导入。 在我工作的地方,我们每天都会这样做 1000 次。 此过程通常不会出现问题,但文件中肯定发生了某些更改。
我收到以下错误:
我已检查以确保“AssignmentID”列存储为“文本” ” 在 Excel 工作表中。 我也尝试过将其更改为一般。 无论设置如何,完全相同的错误。 该字段确实包含数字...我感谢大家对此的帮助!
此致,
弗兰克
I'm trying to import an excel file in to a SQL Server 2000 database using DTS. This is nothing fancy, just a straight import. Where I work, we do this 1000 times a day. This procedure usually works without an issue but something must have changed in the file.
I'm getting the below error:
I've checked to ensure that the column "AssignmentID" is stored as "text" in the excel sheet. I've also tried to change it to general. Exact same error regardless of setting. The field does contain numbers... I appreciate everyone's help on this!
Regards,
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试打开 Excel 文件并查看列内容。
该列中的任何行值是否右对齐? (一般用于数字)?
我猜这样的争吵可能会是一个问题。
Try opening at the excel file and see the column content.
Is any of the row value in that column right-aligned? (generally for numbers)?
I am guessing that such a row could be a problem.
这可能是显而易见的,但目标字符串是否足够长以容纳浮点数的字符串表示形式? 我不确定 Excel 是否对显示给您的内容进行四舍五入,因此可能值得尝试使用更宽的列。
It may be obvious, but is the destination string long enough to hold the string representation of the float? I'm not sure if Excel is rounding what it displays to you, so it may be worth trying with a wider column.
答案与该过程需要文本这一事实有关,但即使您将属性(在格式对话框中)设置为“文本”,Excel 也可能不会将数据作为文本处理。 因此,SQL Server(或库)不会将其处理为文本。
当程序尝试导入它时,系统认为它正在从数字转换为文本,并且预计数据可能会丢失(即使不会丢失数据)并引发错误。
如果我发现可以通过在每个列出的数字前放置一个 '(撇号)来解决此错误。 [IE '124321] 这会强制 excel 将数字视为文本。
希望这能帮其他人解决我现在所面临的头痛问题。 :-)
问候,
弗兰克
The answer has something to do with the fact that the procedure is expecting text but even if you set the properties (in the format dialog) to "text", excel may not handle the data as text. And hence, SQL Server (or the libraries) won't handle it to text.
When the procedures try to import it, the system feels that it is converting from a number to text and it expect that data maybe lost (even though no data will be lost) and the error is raised.
If figured out that I can get around this error by placing a ' (apostrophe) before each listed number. [I.E. '124321] This force excel to treat the number as text.
Hopefully this will save others the headache I now have from this. :-)
Regards,
Frank