October 9, 2009 at 8:20 am
Hi have a table that I want to put the data of multiple columns into a @Body variable so it can be emailed. I'm really unsure of how to do this without a loop or cursor.
The table will contain data like so:
InvoiceNo varchar Message varchar
12345 Failed to Export
56978 Issue with Customer
The @Body should look something like this.
There were issues processing these invoices:
12345 - Failed To Export
56978 - Issue with Customer
I would then execute a CDOSend to email the "report" to the appropriate person.
I know this can be done with a cursor that's easy... but how if at all could it be done without a Cursor/Loop?
October 9, 2009 at 9:29 am
DECLARE @Body NVARCHAR(2000)
SELECT
@Body = @Body + InvoiceNo + ' - ' + Message + CHAR(13) + CHAR(10)
FROM ....
WHERE ...restriction for one contact.
This should work for one contact at a time.
---------------------------------------------
[font="Verdana"]Nothing is impossible.
It is just a matter of time and money.[/font]
October 9, 2009 at 9:37 am
Yeah but I want to get messages for multiple invoices in one email.... so I would still have to do a loop or a cursor with your code.
October 9, 2009 at 9:46 am
No. I don't think so.
How do you know which invoices to use? Use the same logic in the WHERE clause.
---------------------------------------------
[font="Verdana"]Nothing is impossible.
It is just a matter of time and money.[/font]
October 9, 2009 at 10:57 am
I missed the @Body = @Body + part....
That does work. Thanks for the help.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply