April 26, 2011 at 11:56 am
Found this thread trolling for answers to the same question. Here's what works for me.
exec msdb.dbo.sp_send_dbmail
@profile_name = 'YOUR_PROFILE',
@Recipients= 'YOUR_EMAIL',
@Subject= 'sample message with attached query',
@Body= 'sample message with attached query',
@query = 'set nocount on select top 10 * from sys.tables',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'sample.csv',
@query_result_separator = ',',
@query_result_header = 0,
@query_result_no_padding = 1,
@exclude_query_output = 1
August 13, 2012 at 2:32 am
@query_result_separator='', (i.e TAB between quotation marks)
Thanks you so much , this worked for me . Simply cut and paste in today my query and BING , i get correct CSV files at last. 😀
June 25, 2014 at 8:59 am
So what do you use to specifiy a tab?
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply