Send email in a tabular format - last two columns results are combining

  • Sorry wrong post. Thanks

  • Try this?

    DECLARE @xml NVARCHAR(MAX)

    DECLARE @body NVARCHAR(MAX)

    SET @xml = CAST((

    SELECT

    [JobName] AS 'td', '',

    [step_id] AS 'td', '',

    [step_name] AS 'td', '',

    [RunTime] AS 'td', '',

    [RunStatus] AS 'td'

    FROM [JobStatus]

    FOR XML PATH('tr'), ELEMENTS ) AS NVARCHAR(MAX))

    SET @body ='<html><body><H3>Job Run Status</H3>

    <table border = 1>

    <tr>

    <th> JobName </th>

    <th> step_id </th>

    <th> step_name </th>

    <th> RunTime </th>

    <th> RunStatus </th>

    </tr>'

    SET @body = @body + @xml +'</table></body></html>'

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'testProfile',

    @recipients='ramana3327@yahoo.com',

    @subject = ' jobs run status',

    @body = @body,

    @body_format ='HTML' ;

  • Thank you.

    I miss that ,'' and changed later.

    Here SET @body ='<html><body><H3>All Jobs Run Status</H3>

    what does it do when we use H3?

  • ramana3327 (12/3/2015)


    Thank you.

    I miss that ,'' and changed later.

    Here SET @body ='<html><body><H3>All Jobs Run Status</H3>

    what does it do when we use H3?

    The <H3> tag is standard HTML. It specifies that the text between the tags is formatted as a heading level 3.

    www.wcschools.com has a great tutorial on HTML (and a few other things) if you need a reference.

  • Thank you

  • Hi,

    Thanks for your replies.

    I am working the similar kind. I am using the same query but just the columns are different.

    In the query there is an end time, which has 'Null' but from the above, I am not getting any null values.

  • ramana3327 (12/7/2015)


    Hi,

    Thanks for your replies.

    I am working the similar kind. I am using the same query but just the columns are different.

    In the query there is an end time, which has 'Null' but from the above, I am not getting any null values.

    I'm sorry, but you're going to have to give us something more to go on. You've been around here a while, so you know how this works. See the third link in my signature if you need to.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply