Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
wondering_sa
Starting Member
8 Posts |
Posted - 2011-12-22 : 13:39:10
|
If I am not posting to the right place, please accept my sincere apologies, and move to the appropriate location. Thank you!=============================SQL7 and SQL2005 - can use either one of them.I have a simple Query1 that extracts information from Table1. Would like to run this query about 40 times with different parameters passed from Table2 (RecipientNumber field), and then email results in Excel format to 40 different addresses passed from the same Table2 (RecipientEmailAddress field). Table2 consists of two columns: RecipientNumber - used for the Query1, and RecipientEmailAddress - used for the email routine.I could extract with DTS (hard coding RecipientNumber one by one), and then email with xp_sendmail (hard coding RecipientEmailAddress one by one), but Table2 is frequently updated. Is there something that would allow reuse of the same DTS, while passing RecipientNumber from Table2 dynamically (?looping?)? And then, maybe "looping" through all RecipientEmailAddress entries (matching Excel file name by RecipientNumber) with xp_sendmail to send out attachments? .. Or any other suggestions are greatly appreciated!  |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
wondering_sa
Starting Member
8 Posts |
Posted - 2011-12-22 : 14:38:10
|
| I am trying to send custom output (from Table1) to different users (from Table2) in Excel format. Why you think I need a JOIN? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
wondering_sa
Starting Member
8 Posts |
Posted - 2011-12-22 : 16:55:23
|
| Thank you for your reply!This is the simple query that extracts grades for every student:-----------------------------------------SELECT Student, Class, Grade, CommentsFrom GradesWHERE Student = "9645"-----------------------------------------The second table contains Student numbers (the same like in Grades table), and email address for every student.Would like to run the query above for every student, and then send every student her/his grades in Excel format.Thanks again. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-23 : 01:41:50
|
| [code]SELECT g.Student, Class, Grade, Comments,sn.emailaddress,..From Grades gINNER JOIN StudentNumbers snON sn.Student = g.Student[/code]and you can use bcp or OPENROWSET or export/import wizard to sent result in a excel------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|