0

Would someone please help me to write a SQL SP that would query two tables and email the people in the second column of the TableB. The structure of the tables are as below:

TableA

ColumnA(Pkey) ColumnB (Identical Column to ColumnA of the TableB)
-----------------------
Value1        ValueB1                     
Value2        ValueB2
Value3        ValueB3
Value4        ValueB1
Value5        ValueB1

TableB

ColumnA       ColumnB
-----------------------
ValueB1       User1
ValueB2       User2
ValueB3       User3

Email Format for User1:

Dear User1,

"Below are your query results:"

    ColumnA(From TableA)   ColumnB(From TableB)
    Value1                 ValueB1 
    Value4                 ValueB1
    Value5                 ValueB1

And the same email to the remaining usersB and C which corresponds to the values in TableA and TableB.

Thank you so much!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3314399
  • 317
  • 4
  • 9
  • 23

1 Answers1

0

Please disregard. I just made two SPs. One with the sp_send_dbmail and included the Parameters and the 2nd SP to query the list values from Table B and pass them to the store Procedure I made for the sp_send_dbmail. This code by XN16 is gold!

https://stackoverflow.com/a/11852882/3314399

Community
  • 1
  • 1
user3314399
  • 317
  • 4
  • 9
  • 23