尽管在每列使用varchar(MAX),导入CSV文件时SQL Server中的错误 [英] Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column

查看:1211
本文介绍了尽管在每列使用varchar(MAX),导入CSV文件时SQL Server中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图插入一个大的CSV文件(几个gigs)到SQL Server,但一旦我通过导入向导,最后尝试导入该文件,我得到以下错误报告:




  • 执行(错误)
    消息
    错误0xc02020a1:数据流任务1:数据转换失败。列标题的数据转换返回状态值4和状态文本文本已截断或一个或多个字符在目标代码页中无匹配。
    (SQL Server导入和导出向导)


  • 错误0xc020902a:数据流任务1:Source - Train_csv.Outputs [ ] .Columns [Title]失败,因为发生截断,并且Source - Train_csv.Outputs [Flat File Source Output] .Columns [Title]上的截断行部署指定截断时失败。在指定组件的指定对象上发生截断错误。
    (SQL Server导入和导出向导)


  • 错误0xc0202092:数据流任务1:处理文件C:\Train
    (SQL Server导入和导出向导)


  • 错误0xc0047038:数据流任务1:SSIS错误代码DTS_E_PRIMEOUTPUTFAILED 。 Source - Train_csv上的PrimeOutput方法返回错误代码0xC0202092。当管道引擎调用PrimeOutput()时,组件返回失败代码。故障代码的含义由组件定义,但错误是致命的,并且流水线停止执行。可能有在此之前发布的错误消息与更多关于失败的信息。
    (SQL Server导入和导出向导)




我创建了表格,和我设置每列保持varchar(MAX),所以我不明白我仍然可以有这个截断问题。我在做错了什么?

解决方案

在SQL Server导入和导出向导中,您可以调整源数据类型高级选项卡(如果创建一个新表,这些将成为输出的数据类型,否则只用于处理源数据)。



数据类型与MS SQL中的数据类型不同,而不是 VARCHAR(255) DT_STR 并且输出列宽度可以设置为 255 VARCHAR(MAX) DT_TEXT



,在数据源选择中的高级选项卡中,将任何违规列的数据类型从 DT_STR 更改为 DT_TEXT (您可以选择多个列,并一次更改所有列)。




I'm trying to insert a large CSV file (several gigs) into SQL Server, but once I go through the Import Wizard and finally try to import the file I get the following error report:

  • Executing (Error) Messages Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column ""Title"" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)

  • Error 0xc020902a: Data Flow Task 1: The "Source - Train_csv.Outputs[Flat File Source Output].Columns["Title"]" failed because truncation occurred, and the truncation row disposition on "Source - Train_csv.Outputs[Flat File Source Output].Columns["Title"]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component. (SQL Server Import and Export Wizard)

  • Error 0xc0202092: Data Flow Task 1: An error occurred while processing file "C:\Train.csv" on data row 2. (SQL Server Import and Export Wizard)

  • Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - Train_csv returned error code 0xC0202092. The component returned a failure code when the pipeline engine called 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)

I created the table to insert the file into first, and I set each column to hold varchar(MAX), so I don't understand how I can still have this truncation issue. What am I doing wrong?

解决方案

In SQL Server Import and Export Wizard you can adjust the source data types in the Advanced tab (these become the data types of the output if creating a new table, but otherwise are just used for handling the source data).

The data types are annoyingly different than those in MS SQL, instead of VARCHAR(255) it's DT_STR and the output column width can be set to 255. For VARCHAR(MAX) it's DT_TEXT.

So, on the Data Source selection, in the Advanced tab, change the data type of any offending columns from DT_STR to DT_TEXT (You can select multiple columns and change them all at once).

这篇关于尽管在每列使用varchar(MAX),导入CSV文件时SQL Server中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆