0

I am trying to import from a .tsv (or .txt) Flat File Source using the Import and Export Wizard in SQL Server 2016 (using SSMS). I have 3 files that I am importing, and the first two imported with no problems. The third file starts importing, but stops after ~100K rows (and the file is ~1.6M rows).

The error messages I receive are as follows:

Copying to [dbo].[filename] (Error)

Messages

  • Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column "keyword" 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 - members_tsv.Outputs[Flat File Source Output].Columns[keyword]" failed because truncation occurred, and the truncation row disposition on "Source - members_tsv.Outputs[Flat File Source Output].Columns[keyword]" 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:............\filename.tsv" on data row 118345. (SQL Server Import and Export Wizard)

  • Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - members_tsv 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)

The data contained in row 118345, column 12 is "Harmon Medical and Rehabilitation Hospital Positions". This is greater than 50 characters.

The source file is UTF-8 encoded. The collation of the database is SQL_Latin1_General_CP1_CI_AS. When I go to import, I change the Code Page to 65001 (UTF-8).

The column definitions that I have tried are as follows:

CREATE TABLE [dbo].[members3] (
    [member_id] nvarchar(100),
    [date] nvarchar(100),
    [email_domain] nvarchar(100),
    [first_name] nvarchar(100),
    [city] nvarchar(100),
    [state] nvarchar(100),
    [zip] nvarchar(100),
    [degree_level] nvarchar(100),
    [hs_or_ged_year] nvarchar(100),
    [pcp_score] nvarchar(100),
    [keyword] nvarchar(100)
);

And

CREATE TABLE [dbo].[members3] (
    [member_id] varchar(100),
    [date] varchar(100),
    [email_domain] varchar(100),
    [first_name] varchar(100),
    [city] varchar(100),
    [state] varchar(100),
    [zip] varchar(100),
    [degree_level] varchar(100),
    [hs_or_ged_year] varchar(100),
    [pcp_score] varchar(100),
    [keyword] varchar(100)
);

I have also tried increasing the number of characters to 500, also with no success. It seems like even when I change the number of characters that it will accept to something greater than 50, it still will not allow me to import data that is greater than 50 characters. I'm wondering if there is something in global settings that I might need to change...

I have tried searching for someone with a similar problem or the same error message but have not come across anything that solves my problem. Any help would be much appreciated!

Ajp
  • 1
  • 2
  • _"I know that it is not an issue with the data itself"_ >> apparantly you do not know, and the problem is the data. The error message is saying: _Text was truncated or one or more characters have no match in the target code page_. If I had to guess, I would say it's the latter that is causing the problem, i.e. a character in the source file that is not available in the code page of the target column. – TT. Aug 27 '17 at 05:26
  • Even if the error is the data, it successfully imported to Access (and perhaps had a single row with an error rather than not finishing the import). However, I need it in SQL Server, not Access. Any suggestions on how I can bypass this error or solve it? – Ajp Aug 27 '17 at 18:33
  • Check the encoding of the source file, check the collation (and thus code page) and see if they are compatible. Also, to get any decent answer, you should post the source data line that is giving problems, the encoding of the file, the column definition to which you are importing and the collation on that column. Otherwise people can only guess. – TT. Aug 27 '17 at 18:41
  • The source file is UTF-8 encoded. The collation of the database is SQL_Latin1_General_CP1_CI_AS. When I go to import, I change the Code Page to 65001 (UTF-8). The column definition that I am using is as follows: CREATE TABLE [dbo].[members3] ( [member_id] nvarchar(100), [date] nvarchar(100), [email_domain] nvarchar(100), [first_name] nvarchar(100), [city] nvarchar(100), [state] nvarchar(100), [zip] nvarchar(100), [degree_level] nvarchar(100), [hs_or_ged_year] nvarchar(100), [pcp_score] nvarchar(100), [keyword] nvarchar(100) ) – Ajp Aug 28 '17 at 16:56
  • Please [edit] your question, and include data row 118345 from "C:............\filename.tsv". – TT. Aug 28 '17 at 17:37

1 Answers1

1

Please follow these steps :

1. Check value at Row no 118345 and column 12(keyword) remove it and try to insert data based on error generated :

--"An error occurred while processing file "C:............\filename.tsv" on data row 118345."

--"Data conversion failed. The data conversion for column "keyword" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page."

problem may be with data character.

2. Either increase size of column "Keyword" more than (100) or change datatype to Varchar instead of nvarchar.

Regards,

  • Thanks for the suggestion. I started with removing the value in 118345, column 12 ("Harmon Medical and Rehabilitation Hospital Positions", which is longer than 50 characters) and importing again. This time I tried leaving all fields as varchar(500). It made it further this time, but still stopped on a different row (and that row also has a value >50 characters). It seems like it is not allowing me to import anything longer than 50 characters even when I change this in the import settings. Is there somewhere that I have to change global settings for varchar length? – Ajp Aug 28 '17 at 20:46
  • Are you sure your properly redefining the table? Are you dropping the table and recreating the new definition in its place? I find it suspicious that both definitions have the same name of `[dbo].[members3]`. – Chad Harrison Aug 28 '17 at 21:24
  • Each time I imported, I would delete the table in the database first. I am importing from the same source file, so it takes its name from the source file. – Ajp Aug 29 '17 at 17:37
  • Please check these options : https://stackoverflow.com/questions/8629024/text-was-truncated-or-one-or-more-characters-had-no-match-in-the-target-code-pag – Manisha Sharma Aug 30 '17 at 11:42
  • https://stackoverflow.com/questions/25554418/text-was-truncated-or-one-or-more-characters-had-no-match-in-the-target-code-pag/27139415 – Manisha Sharma Aug 30 '17 at 11:44