Unexpected Result in sp_send_dbmail file attachment

  • Hello all,

    I'm encountering a strange issue when attaching a file to sp_send_dbmail, the query runs and mail is delivered correctly, however every other line has a 0 result.

    Example:

    Row 1: Data, Data, Data, Data, Data...

    Row 2: 0

    Row 3: Data, Data, Data, Data, Data...

    Row 4: 0

    .....

    My Query

    EXEC msdb.dbo.sp_send_dbmail

    @Profile_Name = 'OrderMailer',

    @recipients = 'a@b.com',

    @subject = 'Invoices',

    @execute_query_database = 'MyDB',

    @query = @querystring,

    @query_result_separator = ',',

    @query_attachment_filename = 'abc.csv',

    @attach_query_result_as_file = 1,

    @exclude_query_output = 1,

    @query_result_header = 0

    set @queryString =

    ' SET NOCOUNT ON;

    select a.InvoiceID, a.SalesID, PurchaseOrder, ....

    the @queryString param will run in QA with correct results.

    Anyone have any ideas?

Viewing 0 posts

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