Question : Import data from as400 to sql server 2005

I'm importing data from as400 to sql 2005 using ibm db2 udb for iseries ibmda400 ole db provider.  My problem is when users copy and paste text from email in outlook using html and paste it in the green screen, some type of formatting character is inserted also.  The 400 ignores it but as I'm importing the data to the sql server it errors with error below.  
Code Snippet:
1:
Error 0xc020901c: Data Flow Task: There was an error with output column "DOMNOTES" (17) on output "OLE DB Source Output" (11). The column status returned was: "Text was truncated or one or more characters had no match in the target code page.".

Answer : Import data from as400 to sql server 2005

I think the easiest thing to do is to identify the problem character(s), and replace them with something harmless in the source.  Inspect the records that fail,and identify the offending character(s).  Note that the green-screen command DSPPFM offers a hex viewing mode that is handy for this purpose.

For example, let's say the offending character is always the same - an x'20'.  Open up a green-screen session and use the STRSQL command (or use Navigator, or use any other query facility that you are comfortable with that will pass a native SQL query through to DB2/400 for execution:

UPDATE tablename set DOMNOTES = TRANSLATE(DOMNOTES,X'20','?')

This will update the DOMNOTES field in every record, translating ant x'20' characters that it finds to question marks (or whatever character you specify.

You can also handle multiple character mappings at once, just contcatenate together the bad characters in the second Translate parameter, and the target characters in the third parameter:

UPDATE tablename SET Domnotes = TRANSLATE(Domnotes,x'20' || x'21', '??')

Every time TRANSLATE encounters and x'20' it maps it to "?".  Every time an x'21' is encountered, it also gets mapped to a "?".

I didn't test this, so you may have to tweak a bit.  Of course, test it over test data!

DB2/400 SQLTRANSLATE function:   http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/db2/rbafzmstscale.htm (Search the list fot TRANSLATE).

- Gary Patterson


Random Solutions  
 
programming4us programming4us