1

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jaime Fung
  • 11
  • 1
  • How many records do you get when you execute your stored procedure in SSMS? –  Apr 25 '19 at 18:40
  • I get all the records, even if I do a select without the procedure I get more rows than the attached query file – Jaime Fung Apr 26 '19 at 15:14

0 Answers0