简体   繁体   English

SQL Server导入和导出向导

[英]SQL Server Import and Export wizard

I am importing a CSV file into an existing Database and am getting a few errors 我正在将CSV文件导入到现有数据库中,并且遇到一些错误

  • Executing (Error) Messages Error 0xc02020a1: Data Flow Task 1: Data conversion failed. 执行(错误)消息错误0xc02020a1:数据流任务1:数据转换失败。 The data conversion for column "supervisor" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.". 列“主管”的数据转换返回状态值4和状态文本“文本被截断或目标代码页中的一个或多个字符不匹配”。 (SQL Server Import and Export Wizard) (SQL Server导入和导出向导)

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

Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "C:\\Users\\administrator.WDS\\Desktop\\loc800members.csv" on data row 83. (SQL Server Import and Export Wizard) 错误0xc0202092:数据流任务1:在数据行83上处理文件“ C:\\ Users \\ administrator.WDS \\ Desktop \\ loc800members.csv”时发生错误。(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 - loc800members_csv returned error code 0xC0202092. Source-loc800members_csv上的PrimeOutput方法返回了错误代码0xC0202092。 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导入和导出向导)

Here is a sample of the table I am importing. 这是我要导入的表的示例。

http://i.imgur.com/4zsJqgI.jpg http://i.imgur.com/4zsJqgI.jpg

Here is the properties on the supervisor field 这是主管字段上的属性

http://i.imgur.com/r5EonQc.jpg http://i.imgur.com/r5EonQc.jpg

Here are the columns in the table I am importing to. 这是我要导入的表中的列。

i.imgur.com/mD5KlCC.jpg i.imgur.com/mD5KlCC.jpg

From the looks of it, the fields in the database aren't long enough to support the data that you're trying to import. 从外观上看,数据库中的字段不够长,无法支持您要导入的数据。 You'll need to either shorten the data or (probably more ideally) increase the size of the fields in the database. 您需要缩短数据或(可能更理想的情况)增加数据库中字段的大小。 It looks like it's coming from the "supervisor" column (though you might want to double check your other columns to make sure that it doesn't happen elsewhere as well). 看来它来自“主管”列(尽管您可能想仔细检查其他列以确保它也不会在其他地方发生)。

In a nutshell, what's happening, is it's attempting to import everything as is, and eventually hitting a field in your csv file that is too long to properly be copied over. 简而言之,发生的事情是它试图按原样导入所有内容,并最终在csv文件中命中了一个太长的字段,无法正确复制。 Instead of chopping off the remaining data (truncating) it's instead throwing up an error and effectively giving up. 而不是砍掉剩余的数据(截断),而是抛出一个错误并有效地放弃了。 I'm guessing the field in the database is a varchar or nvarchar type with a set size. 我猜数据库中的字段是具有设置大小的varchar或nvarchar类型。 You should be able to just jump the size of this up within the database to pull the data in. You might need to modify relevant stored procedures as well (if there are any), so the data isn't truncated there. 您应该只需要在数据库中增加它的大小就可以提取数据。您可能还需要修改相关的存储过程(如果有的话),因此数据不会在那里被截断。

You can change the field size in the wizard, the default is 50 characters which is often too small. 您可以在向导中更改字段大小,默认值为50个字符,通常太小。

On the "choose a data source" screen, after you have have given the file location and checked off any format things you want to change, then click on advanced. 在指定了文件位置并选中了要更改的所有格式后,在“选择数据源”屏幕上,单击“高级”。 For each field you will see the datatype and output column width. 对于每个字段,您将看到数据类型和输出列宽。 Change it to a larger value. 将其更改为更大的值。 I usually use 500 when looking at a file for the first time until I can see what the actual sizes are. 我通常在第一次查看文件时使用500,直到我看到实际的大小为止。 To change all the column sizes at once, highlight the name of the first column and then hold down the shift key and click on the last column. 要一次更改所有列的大小,请突出显示第一列的名称,然后按住Shift键并单击最后一列。 Then change the size. 然后更改大小。

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

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