可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
- Open the Advanced Editor.
- Under the Input and Output properties, Expand Source Output.
- Expand Output columns
- Select the column which is causing the issue.
- 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.