dbTalk Databases Forums  

Global Variable and email

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Global Variable and email in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
doug
 
Posts: n/a

Default Global Variable and email - 10-18-2006 , 01:39 PM






I have set up a package that runs a query, returns a row count into a global
variable, and then based on that value determines if an email should be sent.
An Active X script in the workflow of the email step is where this
determination is done.

Is it possible to add additional global variables to the query and then
include those values in the text of the email if one is sent? If so, how
would I do this?

Thanks in advance.

Reply With Quote
  #2  
Old   
Todd C
 
Posts: n/a

Default RE: Global Variable and email - 11-22-2006 , 09:26 PM






Are you using an ActiveX Script Task, or the new Script Task? I have used the
latter sucessfully to create the e-mail message:

1) Add a Script Task to the Control Flow.
2) On the second page, list the variables (comma Separated list) that the
script will use to build the string.
In the ReadWrite Variables section, list the varialbe that will hold the
completed script.
3) Click the Design Script button (lower right corner).
4) in the Script itself, enter the appropriate code that follows these
instructions
5) In the SendEMail Task, you can either set up the MessageSourceType as
"Variable" (can't remember if this is an option) then name the variable in
the MessageSource property

OR

5) In the SendEMail task, on the Expressions page, add a new expression for
MessageSource and drag from the Variables to the lower pane.

****************** SAMPLE SCRIPT **************
Dim strInputText as String
strInputText = CStr(Dts.Variables("MyInputVariable").Value

Dim strOutputText as String
strOutputText = "Hi, this is a sample message that says: " & strInputText

Dts.Variables("MyReadWriteVariable").Value = strOutputText

**************** END *******************

A good book on the subject is
A Rational Guide to Scripting SQL Server 2005 Integration Services
by Donald Farmer
ISBN 1-932577-21-1

Hope this helps!
--
Todd Chittenden


"doug" wrote:

Quote:
I have set up a package that runs a query, returns a row count into a global
variable, and then based on that value determines if an email should be sent.
An Active X script in the workflow of the email step is where this
determination is done.

Is it possible to add additional global variables to the query and then
include those values in the text of the email if one is sent? If so, how
would I do this?

Thanks in advance.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.