Import Package Error - Cannot Convert between Unicode and Non Unicode String Data Type

前端 未结 16 561
小蘑菇
小蘑菇 2021-01-31 13:29

I have made a dtsx package on my computer using SQL Server 2008. It imports data from a semicolon delimited csv file into a table where all of the field types are NVARCHAR MAX.

相关标签:
16条回答
  • 2021-01-31 13:59

    Follow the below steps to avoid (cannot convert between unicode and non-unicode string data types) this error

    i) Add the Data conversion Transformation tool to your DataFlow.
    ii) To open the DataFlow Conversion and select [string DT_STR] datatype.
    iii) Then go to Destination flow, select Mapping.
    iv) change your i/p name to copy of the name.

    0 讨论(0)
  • 2021-01-31 14:02

    This a solution that uses the IDE to fix:

    1. Add a Data Conversion item to your dataflow as shown below;

    1. Double click on the Data Conversion item, and set it as shown:

    1. Now double click on the DB Destination item, Click on Mapping, and ensure that your input Column is actually the same as coming from the Copy of [your column name], which is in fact the Data Conversion output NOT the DB Source Output (be careful here). Here is a screenshot:

    And thats it .. save and run ..

    0 讨论(0)
  • 2021-01-31 14:05

    Sometime we get this error when we select static character as a field in source query/view/procedure and the destination field data type in Unicode.

    Below is the issue i faced: I used the script below at source

    and got the error message Column "CATEGORY" cannot convert between Unicode and non-Unicode string data types. as below: error message

    Resolution: I tried multiple options but none worked for me. Then I prefixed the static value with N to make in Unicode as below:

    SELECT N'STUDENT DETAIL' CATEGORY, NAME, DATEOFBIRTH FROM STUDENTS
    UNION
    SELECT N'FACULTY DETAIL' CATEGORY, NAME, DATEOFBIRTH FROM FACULTY
    
    0 讨论(0)
  • 2021-01-31 14:08

    Resolved - to the original ask:

    I've seen this before. Easiest way to fix (don't need all those data conversion steps as ALL of the meta data is available from the source connection):

    Delete the OLE DB Source & OLE DB Destinations Make sure Delayed Validation is FALSE (you can set it to True later) Recreate the OLE DB Source with your query, etc. Verify in the Advanced Editor that all of the output data column types are correct Recreate your OLE DB Destination, map, create new table (or remap to existing) and you'll see that SSIS got all the data types correct (same as source).

    So much easier that the stuff above.

    0 讨论(0)
  • 2021-01-31 14:10

    Non-Unicode string data types:
    Use STR for text file and VARCHAR for SQL Server columns.

    Unicode string data types:
    Use W_STR for text file and NVARCHAR for SQL Server columns.

    The problem is that your data types do not match, so there could be a loss of data during the conversion.

    0 讨论(0)
  • 2021-01-31 14:11

    I changed ValidateExternalMetadata=False for each transformation task. It worked for me.

    0 讨论(0)
提交回复
热议问题