Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Setting the TO email variable using sql select

Author  Topic 

ahouse
Starting Member

27 Posts

Posted - 2010-01-13 : 14:38:32
Hi all,
I'm not sure if I'm going about this the wrong way but I'm having trouble setting a user defined variable in my SSIS package. I see how to set a variable to a SQL function such as GetDate() or to hardcode it with text etc...but I need my variable to be set from a SQL select statement.

The TO variable within an SSIS email function depends on a clientid that I have. So my variable needs to be something like:

Select emailaddress from Clients where ClientID = max(clientid)

I can't figure out where I can set this at. If I do Set @@User_Email or whatever the variable is called, it does not recognize it.

Any ideas?

Andrew

svicky9
Posting Yak Master

232 Posts

Posted - 2010-01-17 : 04:27:23
Hi

Do the following

a. Create a Execute SQL task
b. Create a variable
c. Set the resultset to single row if you are sending a single row
d. Populate the SQL statement
e. go to resultset tab and type in 0 under Resultname and variablename under variable
f. connect the result set to the send email task
g. Go to expressions tab and set the Toline to the variable

Let me know if it works

Thanks
Vivek


http://www.sqlserver007.com
Go to Top of Page
   

- Advertisement -