none
sql mail

    Question

  • can we attach the dataset produced by query or temporary table as an attachment in sql mail.
    Tuesday, November 12, 2013 11:11 PM

Answers

  • Yes u can

    EXEC msdb.dbo.sp_send_dbmail
    	@profile_name = 'PROFILENAME',
    	@recipients = 'abcd@abc.com.au;',
    	@subject = 'test',
    	@body = 'test',
    	@execute_query_database = 'databasename',
    	@query = 'SELECT * from table',
    	@attach_query_result_as_file = 1 ,
    	@query_result_no_padding = 0,
    	@query_attachment_filename = 'results.txt',
    	@query_result_header=0

    Please look in to below link

    http://technet.microsoft.com/en-us/library/ms190307.aspx


    ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you


    • Edited by Eshani Rao Tuesday, November 12, 2013 11:30 PM
    • Marked as answer by rama rose Wednesday, November 13, 2013 12:31 AM
    Tuesday, November 12, 2013 11:18 PM

All replies

  • Yes u can

    EXEC msdb.dbo.sp_send_dbmail
    	@profile_name = 'PROFILENAME',
    	@recipients = 'abcd@abc.com.au;',
    	@subject = 'test',
    	@body = 'test',
    	@execute_query_database = 'databasename',
    	@query = 'SELECT * from table',
    	@attach_query_result_as_file = 1 ,
    	@query_result_no_padding = 0,
    	@query_attachment_filename = 'results.txt',
    	@query_result_header=0

    Please look in to below link

    http://technet.microsoft.com/en-us/library/ms190307.aspx


    ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you


    • Edited by Eshani Rao Tuesday, November 12, 2013 11:30 PM
    • Marked as answer by rama rose Wednesday, November 13, 2013 12:31 AM
    Tuesday, November 12, 2013 11:18 PM
  • Thank you Very Much
    Wednesday, November 13, 2013 12:31 AM