Sql-server – SSIS column cannot convert between unicode and non-unicode string data types

sql serverssis

I am transferring a table from SQL Server to PDA Server. This is my data flow:

ADO NET Source —> OLE DB Destination

All of the columns in my source table are varchars and so when I created my destination table, I made sure that they had the same data types. So both tables have varchar data types for all columns.

However, I am still getting the error: Column "col1" cannot convert between unicode and non-unicode string data types. The weird thing is that if I replace my OLE DB Destination with a ADO Net Destination, it seems to work however, I want to use OLE DB so that I can specifying things such as rows per batch.

Can anyone help?

Best Answer

Double click the line between the source and destination and select the Metadata tab. That will list all of your columns and the data types SSIS has inferred.

I would compare that to your source and 100% ensure they align.

What can happen is that the first time you built your data flow, SSIS will set the metadata based on what the types are at that point. col1 is interpreted to be nvarchar so it'll set it as DT_WSTR of some length.

Time passes and you update the query and the source is now varchar, but still called col1. A varchar will always fit into an nvarchar so the shape of that column hasn't "changed" so SSIS doesn't need to redo it's internals.

If it is the case that SSIS is clinging to old metadata, my click path is to

  1. Copy the existing query
  2. Change my query to SELECT 1 as TotallyNewAndUniqueColumn
  3. SSIS will then report that all my metadata is out of whack and would I like to autofix it, and I click Yes
  4. Repaste the original query and lo and behold, the current metadata is captured.