this one is tough, because i don't have the tables to test agaisnt.
this MIGHT return the email/string you want to send.
if it does, then this query is what you would use as the cursor to send individual emails.
does this return anything liek what you were thinking of sending?
WITH CTE AS
(
SELECT
DISTINCT T2.
FROM dbo.tblCursoArea T1
INNER JOIN tblArea T2
ON T2.IDAREA = T1.IDAREA
INNER JOIN tblEmpleados T3
ON T3.IdArea = T2.IDArea
WHERE T1.PROGRAMADO = 1
)
SELECT T2.,
Notes = STUFF((
SELECT CHAR(13) + CHAR(10)
+ LTRIM(RTRIM(T3.NombreEmpleado))
+ ' ' + LTRIM(RTRIM(T3.ApellidoPaterno))
+ ' '
+ LTRIM(RTRIM(T3.ApellidoMaterno))
FROM dbo.tblCursoArea T1
INNER JOIN tblArea T2
ON T2.IDAREA = T1.IDAREA
INNER JOIN tblEmpleados T3
ON T3.IdArea = T2.IDArea
WHERE ns. = c.
ORDER BY ns.NoteSeq
FOR XML PATH(''),TYPE).value('.','varchar(max)'),1,2,'') --STUFF removes the preceeding CrLf/CHAR13/10
FROM CTE c
ORDER BY ;
Lowell