Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Cannot convert between Unicode & Non Unicode Strings Error Expand / Collapse
Author
Message
Posted Monday, April 1, 2013 10:41 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:34 PM
Points: 16, Visits: 56
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
Post #1437688
Posted Monday, April 1, 2013 11:01 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 10:12 PM
Points: 2,916, Visits: 2,515
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



Post #1437695
Posted Tuesday, April 2, 2013 4:43 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:34 PM
Points: 16, Visits: 56
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
Post #1438127
Posted Tuesday, April 2, 2013 4:45 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:34 PM
Points: 16, Visits: 56
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?
Post #1438128
Posted Tuesday, April 2, 2013 4:50 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 1:18 PM
Points: 896, Visits: 7,075
What is the actual error message and where in the process does it happen?



And then again, I might be wrong ...
David Webb
Post #1438129
Posted Tuesday, April 2, 2013 5:10 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:34 PM
Points: 16, Visits: 56
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
Post #1438130
Posted Tuesday, April 2, 2013 7:59 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:34 PM
Points: 16, Visits: 56
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??
Post #1438148
Posted Tuesday, April 2, 2013 8:13 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 11, 2013 9:34 PM
Points: 16, Visits: 56
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
Post #1438151
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse