sp_send_dbmail - dashes under column headers

  • When I use sp_send_dbmail like this:

    EXEC msdb.dbo.sp_send_dbmail @profile_name='DBS03',@recipients='me@me.co.uk',@subject='Subject'@attach_query_result_as_file=1,@query_attachment_filename='cc.csv', @query_result_separator=',',@query_result_width=500, @execute_query_database='db',@query_result_no_padding =1, @query_result_header=1,@query='SELECT yadda, yadda2 etc'

    the first two lines in the attachment look like this:

    cct_TranNo,cct_created

    ----------,-----------

    Is there a straightforward way of getting rid of the line with all the dashes in it? I know I could set @query_result_header=0 and change my query to

    SELECT 'cct_TranNo,cct_created' UNION ALL SELECT yadda, yadda2 etc but this does seem like an unnecessary step to have to take.

    Thanks

    --
    Scott

  • I looked for a way to do that years ago. Gave up on it. I find convering the recordset to HTML using the XML query method to be so much better that I don't bother with most other methods these days.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I suppose I'm going to have to overcome my distaste for HTML email then 😉

    --
    Scott

  • Or output to CSV or Excel first, then attach the file to an e-mail. That works too, if you don't like HTML e-mail.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Have you considered using Reporting Services instead?

    It is quite good at the sort of thing you seem to be doing here.

Viewing 5 posts - 1 through 4 (of 4 total)

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