SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Cannot convert between Unicode & Non Unicode Strings Error


Cannot convert between Unicode & Non Unicode Strings Error

Author
Message
OscarBoots
OscarBoots
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 151
Hi,

I have a SSIS package that imports an ADO.Net source file & inserts into an OLEDB Destination.

There are about 25 fields but one field errors when tryingto run this task.

The field represents an Account number which is a varchar (15) in both the source & destination tables.

I tried fixing this by adding a Data Conversion node to change the Account number from DT_WSTR to DT_STR as I found an answer on a forum about this problem but no luck, same error.

Can anyone advise how I can fix this & why does it happen?

Thanks
happycat59
happycat59
SSCrazy Eights
SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)SSCrazy Eights (8.7K reputation)

Group: General Forum Members
Points: 8675 Visits: 3281
I think that the ADO.Net provider does an implicit conversion from varchar to nvarchar. If you need to use the ADO.net provider then you will need to convert the value back to varchar.

Is there any particular reason that you are using the ADO.net provider as your source instead of an OLEDB provider ? The OLEDB provider does not do this implicit conversion



OscarBoots
OscarBoots
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 151
Thanks SSCrazy, but I can't use the OLEDB source as it won't connect to my database whereas ADO.NET does.

So I guess I need a workaround for this.

Any ideas?

Thanks
OscarBoots
OscarBoots
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 151
PS, I thought my solution of using a Data Conversion Node to change the data type to varchar was achieving this.

What other options do I have?
David Webb-CDS
David Webb-CDS
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4076 Visits: 8586
What is the actual error message and where in the process does it happen?



And then again, I might be wrong ...
David Webb
OscarBoots
OscarBoots
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 151
Hi David,

I have 3 Nodes now (Including the data Conversion Node) in this Project.

The first is the ADO.NET source to connect to a Data Warehouse

Second is the Data Conversion node where I have changed the Accnt_Number datatype to DT_STR from DT_WSTR

Third is the OLEDB Destination which sends the results to my SQL Server DB.

The third Node has the Red Cross on it & the error is "Column Accnt_Number cannot convert between unicode & non unicode strings"

I initially had only the first & third Nodes, but same error...

Thanks
OscarBoots
OscarBoots
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 151
I found the answer on how to fix this but not yet why it happens.

I used the Import Wizard to create a Package & then looked at how it was constructed.

While stepping through the Import Wizard in SSMS, I found that 5 fields (starting with the 'Accnt_Number' field) had a value in the 'Size' field (11, 15, 15, 16 etc).

These fields were the ones that had to be converted to the DT_STR Data Type & the 'Code Page' field then autopopulates with '1252 (ANSI Latin 1)'

As soon as I had done this the error went away.

I'd like to know how the 'Size' field works & why it causes the need to do a data Conversion...

Should I have saved these fields as another data Type??
OscarBoots
OscarBoots
SSC Veteran
SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)SSC Veteran (246 reputation)

Group: General Forum Members
Points: 246 Visits: 151
I should mention that the 'Size' field is in the 'Data Mapping' option as you select a destination table for the data to transfer to.

Cheers
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search