I have a t-sql i have to loop the variables.
DECLARE @empno nVARCHAR(MAX),@tableHTML NVARCHAR(MAX) ;
set @empno = (select Employee_No from emptemp where active = 'Yes');
SET @tableHTML =
N'<H2>Additions</H2>' +
N'<table border="1">' +
N'<th>Ename</th>' +
N'<th>Sal</th>' +
'<tr>' +
CAST ( ( select td=ename,'',td=sal,'' from emp Where empno = @empno)
FOR XML PATH('tr'), TYPE ) AS NVARCHAR(MAX) ) + N'</table>' ;
EXEC msdb.dbo.sp_send_dbmail
@recipients=someone@gmail.com,
@subject = emp ,
@body = @tableHTML , @body_format = 'HTML',
@profile_name = 'Sql Profile'
The Emptemp table looks like
id empno active
1 245 yes
2 124 yes
3 255 yes
4 224 No
I have to send the individual mail based on the data in emp table