I have created a temp table, the idea being that I want to loop through it, match all records with the same email address and then populate a string, which will go in to an email, then drop the table. This will be run as a stored procedure.
I've used a cursor that first grabbed all the unique email addresses and then coalesce the records but with potentially 100k-500k records performance won't be acceptable, and I know there must be a far more efficient way of doing it.
Example data (apologies, don't know how to format it properly)
#temptable
temp_email, temp_string
test@test.com string1
test@test.com string2
test2@test.com string3
test2@test.com string4
test3@test.com string5
I then want to populate another table with this data
emailto... emailbody
test@test.com 'string1<br / > string2'
test2@test.com 'string3<br / > string4'
test3@test.com 'string5'
Thank you.