Having difficulty with mismatch of string lengths

Venkat Venkataramanan 76 Reputation points
2020-12-23T16:45:40.5+00:00

Hello:

I am using Visual Studio v19. In my integration project, I have a database field defined as VARCHAR(6).

The variable, myField, is defined as string. This defaults to DT_STR of length 10.
The database column is defined as varchar(6).
When I map these two, I get a warning because of the length mismatch.
I have tried using LEFT(myField, 6) results in a DT_STR of length 4. The same is the result when I use the CAST operator.

How can I convert my variable, myField to DT_STR(6)?

Venki

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,450 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Monalv-MSFT 5,891 Reputation points
    2020-12-24T02:57:11.283+00:00

    Hi @Venkat Venkataramanan ,

    Please use the following expression in Derived Column Transformation :

    (DT_STR,6,1252)

    The following pictures will be helpful:

    50928-va.png

    50930-df.png

    51001-derivedcolumn.png

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Hot issues in November--What can I do if my transaction log is full?
    Hot issues in November--How to convert Profiler trace into a SQL Server table?