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
848 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

749 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