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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email SQL query 1

Status
Not open for further replies.

Leangue

Programmer
Joined
Apr 27, 2010
Messages
1
Location
US
Hello Everyone,

I have sql query that returns data in the following format

--------------------------------------------------
userID | email | title | url | description
--------------------------------------------------
1 | email1 | title1 | url1 | description1
1 | email1 | title11 | url11 | description11
2 | email2 | title2 | ur21 | description2
2 | email2 | title21 | url21 | description21

I would like to send an email to each user in the following format: For example user one would receive


UserID 1

title1
url1
description1

title11
url11
description11

How can I accomplish this? I can send one email message for each row but want each user to receive just one message with all their information.

Thanks
 
You could have your initial query save the results to a table and then have your emails run a query to get just the info needed per user. For example, based on your results above...

Code:
xp_sendmail 
   @recipients = <user 1 email address>
  ,@subject = 'User 1 Information'
  ,@query = 'SELECT * FROM results_table WHERE UserID = 1'

You would have one step for each user.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top