SSIS package column errors cannot convert between unicode and non unicode data types

  • I have a source column where - col1 varchar and in OLEDB source we are doing

    select ltrim(rtrim(col1)) as col,

    and in destination the col1 is char.

    In SSIS package I am still facing error even after adding data conversion component - and make it as Unicode String [ DT_WSTR]

    Any idea where I am doing mistake?

  • Both char and varchar are non unicode strings. You don't want to do a conversion to DT_WSTR if your source and destination fields are either of these types. Take the conversion out and that should fix the problem.

    In SQL the unicode data types are nchar and nvarchar. If you had a source of nchar and a destination of varchar, then you would need to do a conversion to DT_STR, and to DT_WSTR if the reverse were true.

    (n)char means that the string will be stored as a fixed length and any unused characters are filled with whitespace. An (n)varchar is stored with a variable length (hence the var prefix), up to a declared maximum length. For example, storing "Home" in a char(10) and varchar(10) would give you the following values respectively:
    'Home      ' --char
    'Home' --varchar

    Hope that helps.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply