Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSIS Convert Between Unicode and Non-Unicode Error

I have an ssis package where I am using an OLEDB source linking to SQL Server 2005 table. All columns except a date column are NVARCHAR(255). I am using an Excel destination and using a SQL statement to create the sheet in the Excel workbook, the SQL is in the excel connection manager (effectively a create table statement that creates a sheet) and is derived from the mapping of the columns from the DB.

No matter what I have done I keep getting this unicode --> non-unicode conversion error between my source and destination. Tried conversion to string[DT_STR] between S > D, removed it, changed SQL Table VARCHAR to NVARCHAR and still get this flippin error.

Because I am creating the sheet in Excel with a SQL statement I do not see any way to actually pre-define what the data types of the columns will be in the Excel sheet. I imagine it would be a default meta data but I do not know.

So between my SQL table destination and the creation of my Excel sheet with this SSIS sql statement how can I stop this error coming up?

My error is:

Error at Data Flow Task [OLE DB Source [1]]: Column "MyColumn" cannot convert between unicode and non-unicode string data types.

And for all nvarchar columns.

Appreciate any help

Thanks

Andrew

like image 600
Andrew Avatar asked Mar 21 '13 12:03

Andrew


People also ask

What is the difference between Unicode and non-Unicode in SSIS?

The only difference between the Unicode and the non-Unicode versions is whether OAWCHAR or char data type is used for character data. The length arguments always indicate the number of characters, not the number of bytes.

How can I resolve the Unicode and non-Unicode data issue while importing Excel data into SQL Server?

We need to add a Data Conversion task from our SSIS Toolbox between the Excel Source and the OLE DB Destination. This will allow us to convert the data from Unicode to Non-Unicode. If you double click the Data Conversion item, you can now tell it what you want to convert.

Is Excel Unicode or non-Unicode?

By default Excel data is treated as Unicode and also by default when you create new tables SQL Server will make your character type columns Unicode as well (nchar, nvarchar,etc...)


1 Answers

Below Steps worked for me:

  1. right click on source task.

  2. click on "Show Advanced editor".

advanced edit option for source task in ssis

  1. Go to "Input and Output Properties" tab.

  1. select the output column for which you are getting the error.

  2. Its data type will be "String[DT_STR]".

  3. Change that data type to "Unicode String[DT_WSTR]".

Changing the data type to unicode string

  1. save and close.

Hope this helps!

like image 78
amar_soni Avatar answered Sep 17 '22 00:09

amar_soni