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

前端 未结 16 607
小蘑菇
小蘑菇 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 14:12

    At some point, you're trying to convert an nvarchar column to a varchar column (or vice-versa).

    Moreover, why is everything (supposedly) nvarchar(max)? That's a code smell if I ever saw one. Are you aware of how SQL Server stores those columns? They use pointers to where the column is stored from the actual rows, since they don't fit within the 8k pages.

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

    Get to the registry to configuration of the client and change the LANG. For Oracle, go to HLM\SOFTWARE\ORACLE\KEY_ORACLIENT...HOME\NLS_LANG and change to appropriate language.

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

    Two solutions: 1- if the type of the target column is [nvarchar] it should be change to [varchar]

    2- Add a "Derived Column" component to the SSIS package and add a new column with the following expression:
    (DT_WSTR, «length») [ColumnName]

    Length is the length of the column in the target table and ColumnName is the name of the column in the target table. finally at the mapping part you should use this new added column instead of the original column.

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

    Not sure if this is still a problem but I found this simple solution:

    1. Right-Click Ole DB Source
    2. Select 'Edit'
    3. Select Input and Output Properties Tab
    4. Under "Inputs and Outputs", Expand "Ole DB Source Output" External Columns and Output Columns
    5. In Output columns, select offending field, on the right-hand panel ensure Data Type Property matches that of the field in External Columns properties

    Hope this was clear and easy to follow

    0 讨论(0)
  • 2021-01-31 14:17
    1.add a Data Conversion tool from toolbox
    2.Open it,It shows all coloumns from excel ,convert it to desire output. take note of the Output Alias of
    each applicable column (they are named Copy Of [original column name] by default)
    3.now, in the Destination step, click on Mappings
    
    0 讨论(0)
  • 2021-01-31 14:18

    Not sure if this is a best practice with SSIS but sometimes I find their tools are a bit clunky when you want to do this type of activity.

    Instead of using their components you can convert the data within your query

    Instead of doing

    SELECT myField = myNvarchar20Field
    FROM myTable
    

    You could do

    SELECT myField = CONVERT(VARCHAR(20),myNvarchar20Field)
    FROM myTable
    
    0 讨论(0)
提交回复
热议问题