0

I have set of files which arrive in the below fashion

mmyy_dgmaker.csv mmyy_xlsx

I have attached the photo of the files enter image description here

In my SSIS task I have taken for each loop container

  • In expression I have given file directory as varfiledirectory
  • variable as varfilename Inside for each loop I have taken file system task editor Source variable is : var source Destination is var _ destination for var destination I have used below expression enter image description here

Now the problem is it is replacing for all the file in the folder with 15 characters from right which should not be the case need help so that it should take only those files specifically has more length and the rest should be imported as it is.

Thanks.

1 Answer 1

0

If I have understood you correctly the script should look like:

@[User::Var_Destination_Path] + 
    (LEN(@[User::Var_File_Name]) > 15 ? 
        LEFT(@[User::Var_File_Name], LEN(@[User::Var_File_Name]) - 15) + ".csv" : 
        @[User::Var_File_Name])

This expression evaluates whether the filename has more than 15 characters. If the condition is met, it removes the final 15 characters from the filename and adds the "*.csv" extension. If the filename has 15 or fewer characters, it remains unchanged.

Instead of replacing with empty characters I used LEFT function.

Sign up to request clarification or add additional context in comments.

1 Comment

I used the above expression in my task I'm getting error as The length -15 specified for function "LEFT" is negative and is not valid. The length parameter must be positive. code 0xC00470E7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.