Add check length of column code before insert into table.

  • I have a package that I want check before inserting the length of the data being inserted.  The data has to be 4 digits anything less or more needs to be ignored.  For example I have an Account column 4444 will get inserted but 444 will not get inserted and should be ignored.  I know I can use a conditional split but how would I write the expression?  I'm new to expressions and SSIS any help would be appreciated.

  • I assume all you need it this:

    LEN((DT_WSTR, 4) [Your Column]) == 4

    If the values can also be longer than 4 characters as well increase the length of the WSTR, otherwise you''ll receive a truncation error.

    Thom~

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

  • Thom A wrote:

    I assume all you need it this:

    LEN((DT_WSTR, 4) [Your Column]) == 4

    If the values can also be longer than 4 characters as well increase the length of the WSTR, otherwise you''ll receive a truncation error.

    I think you may need a bit more than this to make a full conditional expression. See link.

     

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Phil Parkin wrote:

    Thom A wrote:

    I assume all you need it this:

    LEN((DT_WSTR, 4) [Your Column]) == 4

    If the values can also be longer than 4 characters as well increase the length of the WSTR, otherwise you''ll receive a truncation error.

    I think you may need a bit more than this to make a full conditional expression. See link.

    Conditional Splits require a boolean result, not a Scalar value to determine if the row is retained or not. If true, the row goes to the "True" data flow route, otherwise the "False" data flow route. See SSIS Basics: Using the Conditional Split.

    Thom~

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

  • OK, now I understand why you wrote that.

    Despite mention of the CS by the OP, my assumption was that this was a data flow containing multiple columns, one of which needed to be NULLed in certain circumstances.

    But if the entire row needs to be conditionally ignored, you are, of course, correct.

    If this is true and the source data is from a database, the OP should consider filtering out those rows via a suitable WHERE clause.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • That worked for me Thom thanks.

Viewing 6 posts - 1 through 5 (of 5 total)

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