saturation
asked on
SQL e-mail -- loop through returned records
I am trying to send an HTML email with rows of records in an HTML table format. I have my SELECT statement as well as the SP to send the e-mail, but I have no idea how to loop through the records from the select statement and put them into a table format within SQL. Help?
select refid, name, person from valerts
EXEC msdb.dbo.sp_send_dbmail
@recipients =N'myemail@gmail.com',@bod y = 'test',@body_format ='HTML',@subject ='Message Subject',@profile_name ='DatabaseMailProfile'
select refid, name, person from valerts
EXEC msdb.dbo.sp_send_dbmail
@recipients =N'myemail@gmail.com',@bod
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Declare a temp table and store the resultant records in that
Retrieve the recors one-by-one using a cursor and frame thhe HTML
Send that HTML in mail.
Retrieve the recors one-by-one using a cursor and frame thhe HTML
Send that HTML in mail.
https://www.experts-exchange.com/questions/26826472/sp-send-dbmail-format.html