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
839 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:ScottPletcher
  • 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:huslayer
huslayer 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:ScottPletcher
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:ScottPletcher
ID: 33621020
Sorry, this turned out to be a different issue than what I thought I would be.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now