简体   繁体   English

将Excel导入SQL Server

[英]Importing Excel into SQL Server

I want to update a table using data from an excel sheet. 我想使用Excel工作表中的数据更新表格。 My excel file have just two columns, one with a uniqueidentifier and the other with a reference. 我的excel文件只有两列,一列带有uniqueidentifier,另一列带有引用。 I tried to use the OPENROWSET command to update my table, but the database have a security property that doesn't allows me to do it. 我试图使用OPENROWSET命令更新表,但是数据库具有一个安全属性,该属性不允许我这样做。

My idea now is to create a new table in my database with those two columns, and update the data in my table later. 我现在的想法是使用这两列在数据库中创建一个新表,并稍后更新表中的数据。 To create the data in my database I tried to use the Import Wizard in SQL Server but when I tried to do it, I got the following messages: 为了在数据库中创建数据,我尝试在SQL Server中使用导入向导,但是当我尝试执行此操作时,收到以下消息:

Error 0xc020901c: Data Flow Task 1: There was an error with Source - Sheet1$.Outputs[Excel Source Output].Columns[PST_WSI_RefDes] on Source - Sheet1$.Outputs[Excel Source Output]. 错误0xc020901c:数据流任务1:源-Sheet1 $ .Outputs [Excel源输出]。源-Sheet1 $ .Outputs [Excel源输出]上的列[PST_WSI_RefDes]出错。 The column status returned was: "Text was truncated or one or more characters had no match in the target code page.". 返回的列状态为:“文本被截断或目标代码页中的一个或多个字符不匹配。”。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

Error 0xc020902a: Data Flow Task 1: The "Source - Sheet1$.Outputs[Excel Source Output].Columns[PST_WSI_RefDes]" failed because truncation occurred, and the truncation row disposition on "Source - Sheet1$.Outputs[Excel Source Output].Columns[PST_WSI_RefDes]" specifies failure on truncation. 错误0xc020902a:数据流任务1:“源-Sheet1 $ .Outputs [Excel源输出] .Columns [PST_WSI_RefDes]”失败,因为发生了截断,并且截断行位于“源-Sheet1 $ .Outputs [Excel源输出]”上.Columns [PST_WSI_RefDes]“指定截断失败。 A truncation error occurred on the specified object of the specified component. 在指定组件的指定对象上发生了截断错误。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. 错误0xc0047038:数据流任务1:SSIS错误代码DTS_E_PRIMEOUTPUTFAILED。 The PrimeOutput method on Source - Sheet1$ returned error code 0xC020902A. Source-Sheet1 $上的PrimeOutput方法返回错误代码0xC020902A。 The component returned a failure code when the pipeline engine called PrimeOutput(). 当管道引擎调用PrimeOutput()时,该组件返回失败代码。 The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. 故障代码的含义由组件定义,但是错误是致命的,并且管道停止执行。 There may be error messages posted before this with more information about the failure. 在此之前可能会发布错误消息,其中包含有关失败的更多信息。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

I know those messages refer to my data, but my excel file have 12k lines and I don't know what line has problem. 我知道这些消息是指我的数据,但是我的excel文件有12k行,我不知道哪一行有问题。

How to investigate what line has problem? 如何调查哪条线有问题? Or, is there other ways to import data from excel? 或者,还有其他方法可以从excel导入数据吗?

More information: 更多信息:

Sample of data I'm trying to import 我尝试导入的数据样本

C7 (OP1 to OP12), C10 (OP1 to OP12), C3 (IP1 to IP16), C6 (OP1 to OP12), C10, C11, C12, C45, C49, C50, C14 (OP1 to OP12), C5 (OP1 to OP12), C9 (OP1 to OP12), C15 (OP1 to OP12), C51, C52, C54, C55 C7(OP1至OP12),C10(OP1至OP12),C3(IP1至IP16),C6(OP1至OP12),C10,C11,C12,C45,C49,C50,C14(OP1至OP12),C5(OP1至OP12),C9(OP1至OP12),C15(OP1至OP12),C51,C52,C54,C55

Max size of the field: 1303 characters. 字段的最大大小:1303个字符。

Import table format: I've tried two configurations: 导入表格式:我尝试了两种配置:

1 - uniqueidentifier and nvarchar(2000) 1-uniqueidentifier和nvarchar(2000)

2 - nvarchar(200) and nvarchar(2000) 2-nvarchar(200)和nvarchar(2000)

尝试使用Excel2MySQL,它为我省去了很多麻烦。

我相信确实如此,您可以免费下载并试用它,直到您想支付额外的功能。

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

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