I am working on a sql server DB mail sending task in which the mail body should be as HTML. Data has to be pulled from two different table.
Ex.
Table -1[Staging table-Rows keeps on adding]
ID Name C_Name
1 john Mumbai
2 Adam pune
3 Kevin Delhi
Table -2[Static table,config kind]
FieldID FieldName FieldOrder
1 CustomerName 1
2 City 2
My expected HTML mail body is:
<table >
<tr>
<td>
CustomerName</td>
<td>
john</td>
<td>
Adam</td>
<td>
Kevin</td>
</tr>
<tr>
<td>
City</td>
<td>
Mumbai</td>
<td>
pune</td>
<td>
Delhi</td>
</tr>
Table rows continues....
</table>
HTML Table Design:
CustomerName John Adam Kevin
City Mumbai Pune Delhi
Struggling for an optimized query ,please suggest.