Candidochris
asked on
SSIS / BIDS Nvarchar Flat File Export Issue - Text was truncated or one or more characters had no match in the target code page
I'm having an issue with SQL Server 2008R2 64-bit with a BIDS Data Flow Task specifically.
I'm trying to export data from a SQL Server database to a flat file. I have narrowed the problem down to one specific field, which is type NVARCHAR(100) .
I altered my query to only include records that are a problem:
This allowed me to lower the record count to 160 records.
Then I used the 'TOP' command to get as many records to work as I could, which narrowed it further to the following 3 records which cause the problems (I pasted them and included a screen shot).
170608356¿
¿¿¿
пѿÑѿовой - Innovate
My flat file settings look like this:
And the column in question is set as such in the flat file connection manager:
DataType: Unicode String [DT_WSTR]
width 100
textQualifed: True
When I hit run, I get this message:
I have tried the following:
1. Setting the column width to 250 in the advanced tab in the flat file manager
2. Setting TextQualified to False
3. Changing the column type to DT_String , DT_Text, and DT_NText
If I ignore these 3 records, everything works perfectly for all records in the table (100,000+). It's obviously an encoding problem, but I can't figure out how to fix it.
Thanks!
I'm trying to export data from a SQL Server database to a flat file. I have narrowed the problem down to one specific field, which is type NVARCHAR(100) .
I altered my query to only include records that are a problem:
SELECT PoNum FROM SALES WHERE CAST(PoNum AS VARCHAR) != PoNum;
This allowed me to lower the record count to 160 records.
Then I used the 'TOP' command to get as many records to work as I could, which narrowed it further to the following 3 records which cause the problems (I pasted them and included a screen shot).
170608356¿
¿¿¿
пѿÑѿовой - Innovate
My flat file settings look like this:
And the column in question is set as such in the flat file connection manager:
DataType: Unicode String [DT_WSTR]
width 100
textQualifed: True
When I hit run, I get this message:
[Flat File Destination [19]] Error: Data conversion failed. The data conversion for column "NumAtCard" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
I have tried the following:
1. Setting the column width to 250 in the advanced tab in the flat file manager
2. Setting TextQualified to False
3. Changing the column type to DT_String , DT_Text, and DT_NText
If I ignore these 3 records, everything works perfectly for all records in the table (100,000+). It's obviously an encoding problem, but I can't figure out how to fix it.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah! Sorry - for some reason I was thinking you were importing.
Try doing something like this:
select * from tablename where field like '%[^!-}]%'
which means "like any number of characters, a special char, and any number more, where the special char is outside the range from "!" (21 hex, 33 decimal) to "}" (7D hex)"
For the character ranges check http://en.wikipedia.org/wiki/ASCII
I didn't try, but you should be able to use the char function, so replace "!" with char(33), or use char(32) if you have spaces you want to ignore.
hth
Mike
Try doing something like this:
select * from tablename where field like '%[^!-}]%'
which means "like any number of characters, a special char, and any number more, where the special char is outside the range from "!" (21 hex, 33 decimal) to "}" (7D hex)"
For the character ranges check http://en.wikipedia.org/wiki/ASCII
I didn't try, but you should be able to use the char function, so replace "!" with char(33), or use char(32) if you have spaces you want to ignore.
hth
Mike
ASKER
Thanks Mike, that's what I needed.
Great. I'm sorry for the long delay!
So what's next? :)
Mike
So what's next? :)
Mike
ASKER
Mike,
Hopefully everything just works - but like always, I'll post in here if not. I did get this project going and working consistently.
Hopefully everything just works - but like always, I'll post in here if not. I did get this project going and working consistently.
ASKER