Solved

SSIS Send Mail, trying to use user variable for file name, but SSIS is using default value, not reset value

Posted on 2010-08-24
4
844 Views
Last Modified: 2013-11-10
In SSIS, I'm trying to have a dynamic file name for a mail attachment.  I have to include date and time in the file name.

I created a package level variable, set it to a default value (I'm forced to, since that variable is used as source and SQL pre-checks package values), and used a SQL step to set the package-level variable with the file name I need.  

I can use that variable to rename the generic file to my generated file name with the specific date time, so I know that variable's getting properly set (although I don't see the new value in the variable in SSIS debug mode).

My last task is an email step to email the file.  I have set the FileAttachments expression to
@[User::VariableName]
for that task.  

But often the email doesn't work, and when it does, it sends the dummy name that the variable had on entry to the package rather than the generated value I reset the variable to in my SQL step.

What do I need to get the email task to use the *current* variable value to attach the file?
0
Comment
Question by:Scott Pletcher
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
Reza Rad earned 250 total points
ID: 33518453
maybe sql step doesn't work correctly all times,
why you don't set this variable with expression?
just right click on variable, go to properties window, set expression as you want, and also set EvaluateAsExpression property to true
0
 
LVL 21

Assisted Solution

by:Jason Yousef, MS
Jason Yousef, MS earned 250 total points
ID: 33619803
I wanna help but can't get an idea of the how do you populate the VAR, can you post a screen shot of your package along with the variable configuration?
0
 
LVL 69

Author Comment

by:Scott Pletcher
ID: 33621002
This is now working.  It looks like SQL does not display the correct value when running/debugging the script, but that the value does get set when a job runs the package.

I didn't see some of the resulting emails because of the spam filter.  For some reason it was trapping the emails, thus i didn't see them.
0
 
LVL 69

Author Closing Comment

by:Scott Pletcher
ID: 33621020
Sorry, this turned out to be a different issue than what I thought I would be.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question