Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through rows to build aan email

Status
Not open for further replies.

dupuis2387

Programmer
Sep 25, 2006
9
US
Hello,


I have a table with one column, which is populated by a bulk insert statement that enters the values from an ASCII txt file. Each line in that txt file equates to one row in the table. Now I'm using microsoft's sp_smtp to send emails, and I'm trying to figure out how to make the @body variable loop through each row in the table and for each row, create one line that will make up the body of the email.

Is this possible without adding another column to identify each row uniquely?

Gah, I hope I posted this problem with some lucidity...
 
If you don't have an identifier, how can you tell which record belongs to which email? Does the table contain only one email? If it has more than one, you definitely need an identifying column, which you can populate as part of the upload process.

In either case, you can use the COALESCE function to stitch the rows together into a variable that you can use as the @body parameter.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Well, yes it is only one email at a time. table gets dropped and recreated for each email. I'll try coalesce. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top