When I attach my stored procedure to a file by the sp_send_dbmail
the file doesn't have all the rows. For example the total rows are 243 but it only attaches 204 of them. Even if I change the stored procedure by a simple SELECT * FROM TABLE
, the attached file doesn't have all the rows
execute msdb.dbo.sp_send_dbmail
@profile_name ='MyProfile',
@recipients ='MyMail',
--@copy_recipients ='CopyMail',
@blind_copy_recipients='',
@body='BodyText',
@query='SET NOCOUNT ON; exec STORE_PROCEDURE',
@execute_query_database='DATA_BASE',
@attach_query_result_as_file=1,
@query_attachment_filename='FILE.txt',
@query_result_header = 0,
@query_result_width='32767',
@query_result_separator = ' ',
@subject='SOME SUBJECT',
@query_result_no_padding=1;
I expect 243 rows but the file only has 204 rows