SSIS Package: convert between unicode and non-unicode string data types

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

I am connecting to an Oracle DB and the connection works, but I get the following error for some of the columns:

Description: Column "RESOURCE_NAME" cannot convert between unicode  and non-unicode string data types. 

Value for RESOURCE_NAME:

  • For Oracle: VARCHAR2(200 BYTE)
  • For SQL Server: VARCHAR(200 BYTE)

I can connect to the Oracle DB via Oracle SQL Developer without any issues. Also, I have the SSIS package setting Run64BitRuntime = False.

回答1:

The Oracle data type VARCHAR2 appears to be equivalent to NVARCHAR in SQL Server, or DT_WSTR in SSIS. Reference

You will have to convert using the Data Conversion Transformation, or CAST or CONVERT functions in SQL Server.



回答2:

the easiest way around this to to open the ssis package in notepad (the dstx file) and do a global find and replace of all instances of validateExternalMetadata="True" with validateExternalMetadata="False".

note: we encountered this issue when connecting to an Oracle 11g database on Linux through ssis.



回答3:

If the package works in one machine and doesn't in other; Try setting the NLS_LANG to right language, territory and character set and test the package.

[Command Prompt]> set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 


回答4:

on oledb source ->advanced editor options->input/output columns->output columns->select RESOURCE_NAME column and change Data type as DT_WSTR and length also u can change as required



回答5:

You can use SQL command in SSIS and use CONVERT or CAST. If SSIS still gives you an error its because of the metadata. Here is how you can fix it.

  1. Open the Advanced Editor.
  2. Under the Input and Output properties, Expand Source Output.
  3. Expand Output columns
  4. Select the column which is causing the issue.
  5. Go to Data Type Properties and change the DataType to your desired type DT_STR, DT_Text etc.


回答6:

If everything failed from above. Create a table variable and insert the data into it. Then select all records as source. use SET NOCOUNT ON in the script.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!