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
849 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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

752 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