April 7, 2016 at 8:53 am
I am using an expression task inside a foreach loop container to concatenate file names and attempting to keep eack file name on its own line insode an ssis variable. I then place the variable inside the email tasks messagesource expression. I have several different packages and I'm using the same code in an expression task on each package. Im noticing that some will keep the file names on its own line and some wont.
The following code doesn't add the new line ( @[User::Current_File] holds the current file name from the foreach loop). The file names are on one line
@[User::NonEandIFileNamesSent] = @[User::NonEandIFileNamesSent] + "" + @[User::Current_File] + "(" + (DT_STR, 10, 1252) @[User::Number_Rows] + ")"
The code below results in each file name being on its own line ( @[User::Current_File] holds the current file name from the foreach loop). :
@[User::FileNamesSent] = @[User::FileNamesSent] + "" + @[User::Current_File] + "(" + (DT_STR, 10, 1252) @[User::Number_Of_Rows] + ")"
Can anyone explain why one is working correctly and one isn't?
April 7, 2016 at 9:30 am
I don't see where you are adding in a carriage return/new line into the variable. I think you're missing something. I do quite a bit of email message formatting in my packages. One thing I do in every package is I add a package level variable called CRLFTab and I put an expression on that variable with the following value: REPLICATE("\r\t",1). Then, I use it in my expression on message source to format my messages as such:
"Package <package name> encountered an issue, please investiage
Server: <server>
Database: <database>
Error Message: <error>
"
this is obviously a mockup and not a real expression, but I the formatting is what I'm after. Carriage return, new line, tab. You can add a variable with just the carriage return, new line if you don't want the tab.
So back to your problem. One thing you may consider is when building out your file list, don't add the carriage return/new line into that variable. Make your file list a comma separated list. Then, in your expression for your email message source, replace the commas with the carriage return/new line.
April 7, 2016 at 9:43 am
That worked, thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply