• 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!