HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

DB mail sending attachment of size 64 KB only even after increasing maximum file size limit

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterfilemaximumattachmentsizelimitsendingmailincreasingeven

Problem

I am facing an issue with DB mail functionality. I am using SQL Server Agent to trigger mail on success or failure. While sending this, I am also providing an attachment, which consists of some query-generated report.

The problem here is I am able to send mail with attachment but the attachment size is fixed to 64Kb only. I have increased maximum attachment size limit from Database mail configuration, still the same problem exists.

I am executing following lines of code:

EXEC msdb.dbo.sp_send_dbmail
    @profile_name = @profileName,
    @recipients = @recipientsList,
    @body = @Body,
    @subject = @Subject ,
    @body_format = 'HTML',
    @query= @Query,
    @query_attachment_filename=@EmailFileName,
    @attach_query_result_as_file=1,
    @query_result_no_padding = 1,
    @query_result_separator= ' '

Solution

You need to apply Cumulative update package 4 for SQL Server 2014. There was a bug which was fixed in CU4.

Symptoms


Assume that you use Database Mail and sp_send_dbmail stored procedure
with the @query and @attach_query_result_as_file option in Microsoft
SQL Server 2014. The stored procedure run a query and set the
result-set as an attachment of the email. When the query has a large
result-set, the attachment is truncated to 64 kilobyte (KB) maximum.

Resolution


The issue was first fixed in the following cumulative update of SQL
Server.

Details in below link:

FIX: "sp_send_dbmail" stored procedure truncates email attachments to 64 KB in SQL Server 2014

Context

StackExchange Database Administrators Q#188283, answer score: 2

Revisions (0)

No revisions yet.