August 6, 2008 at 9:11 am
How do you reference a package varialbe within the Exec SQL step. My syntax is below, but it will not work.
declare @EMAILTO varchar(50)
declare @SUBJ varchar(50)
declare @BODY varchar(2000)
Select @EMAILTO = Dts.Variables("varEmail")
Select @SUBJ = Dts.Variables("varSubject")
Select @BODY = Dts.Variables("varMsgBody")
EXECUTE msdb.dbo.sp_send_dbmail
@profile_name = 'ArchibusProfile',
@recipients= @EMAILTO,
@subject = @SUBJ,
@body = @BODY
August 7, 2008 at 4:19 am
you need to parameterise your query. replace the code with:
EXECUTE msdb.dbo.sp_send_dbmail
@profile_name = 'ArchibusProfile',
@recipients= ?,
@subject = ?,
@body = ?
Then go to the parameter mapping section of the task and add in the three necessary variables. The parameter name is an integer relating to the position of the parameter in your query. The first parameter would thus be:
Variable Name: varEmail
Direction: Input
Data Type VARCHAR
Parameter Name: 0
Parameter Size: 4000 (at a guess)
The next parameter would have 1 as its name, and so on.
Tom
August 7, 2008 at 8:13 am
I found an example like this yesterday and got this to work by using the Paramter Mapping tab and m,apping my variables to a paramter and referencing them with the ?. Thanks for replying!:)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply