Cannot convert between Unicode & Non Unicode Strings Error

  • Hi,

    I have a SSIS package that imports an ADO.Net source file & inserts into an OLEDB Destination.

    There are about 25 fields but one field errors when tryingto run this task.

    The field represents an Account number which is a varchar (15) in both the source & destination tables.

    I tried fixing this by adding a Data Conversion node to change the Account number from DT_WSTR to DT_STR as I found an answer on a forum about this problem but no luck, same error.

    Can anyone advise how I can fix this & why does it happen?

    Thanks

  • I think that the ADO.Net provider does an implicit conversion from varchar to nvarchar. If you need to use the ADO.net provider then you will need to convert the value back to varchar.

    Is there any particular reason that you are using the ADO.net provider as your source instead of an OLEDB provider ? The OLEDB provider does not do this implicit conversion

  • Thanks SSCrazy, but I can't use the OLEDB source as it won't connect to my database whereas ADO.NET does.

    So I guess I need a workaround for this.

    Any ideas?

    Thanks

  • PS, I thought my solution of using a Data Conversion Node to change the data type to varchar was achieving this.

    What other options do I have?

  • What is the actual error message and where in the process does it happen?


    And then again, I might be wrong ...
    David Webb

  • Hi David,

    I have 3 Nodes now (Including the data Conversion Node) in this Project.

    The first is the ADO.NET source to connect to a Data Warehouse

    Second is the Data Conversion node where I have changed the Accnt_Number datatype to DT_STR from DT_WSTR

    Third is the OLEDB Destination which sends the results to my SQL Server DB.

    The third Node has the Red Cross on it & the error is "Column Accnt_Number cannot convert between unicode & non unicode strings"

    I initially had only the first & third Nodes, but same error...

    Thanks

  • I found the answer on how to fix this but not yet why it happens.

    I used the Import Wizard to create a Package & then looked at how it was constructed.

    While stepping through the Import Wizard in SSMS, I found that 5 fields (starting with the 'Accnt_Number' field) had a value in the 'Size' field (11, 15, 15, 16 etc).

    These fields were the ones that had to be converted to the DT_STR Data Type & the 'Code Page' field then autopopulates with '1252 (ANSI Latin 1)'

    As soon as I had done this the error went away.

    I'd like to know how the 'Size' field works & why it causes the need to do a data Conversion...

    Should I have saved these fields as another data Type??

  • I should mention that the 'Size' field is in the 'Data Mapping' option as you select a destination table for the data to transfer to.

    Cheers

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply