August 13, 2008 at 11:24 am
I was wondering the most efficient way to send an email that has multiple variables. For example I have a stored proc that sends the email and in the body of the email I need to pull info from one table, 4 different columns. What is the most efficient way to do this?? At the present my idea is to do this..
DECLARE @var1 as varchar(10), @var2 as varchar(10), @var3 as varchar(10), @var4 as varchar(10)
SET @var1 = (Select column from table where..)
SET @var2 = (Select column2 from table where..)
ETC...
Then in the email body call each @var....
Is there a better way to do this??
August 13, 2008 at 12:34 pm
if the data is all in the same row, you can do this:a assuming my table has the columns in capitals:
SELECT
@var1=SUBJECT,
@var2=EMAILFROM,
@var3=EMAILTO,
@var4=SUBJECT
FROM PENDINGEMAILS WHERE SUCCESSFULLYSET=0
if they are coming form different WHERE conditions or otehr tables, then you'd need to do a few more, but the idea is you can assign the values in the SELECT statement(assuming there's only one row to grab)
Juan Ordonez (8/13/2008)
I was wondering the most efficient way to send an email that has multiple variables. For example I have a stored proc that sends the email and in the body of the email I need to pull info from one table, 4 different columns. What is the most efficient way to do this?? At the present my idea is to do this..
DECLARE @var1 as varchar(10), @var2 as varchar(10), @var3 as varchar(10), @var4 as varchar(10)
SET @var1 = (Select column from table where..)
SET @var2 = (Select column2 from table where..)
ETC...
Then in the email body call each @var....
Is there a better way to do this??
Lowell
August 13, 2008 at 2:06 pm
Perfect, thanks Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply