I am working on ETL and I have this below sql code in my SQL Task in SSIS package. This is how i have coded. I am selecting a data from a table and result of that query as file. I want this attachment sent in CSV format. How do i do it?
EXEC sp_send_dbmail @profile_name='default',
@recipients='dev@null.com',
@subject=@SUB,
@body=@BODY,
@query= 'SELECT [MID],[HID],[MeC],[LC],[RowCDate]
FROM [JBC].[dbo].[Table1] WHERE RowCDate >= GETDATE()
',
@attach_query_result_as_file=1
Any help will be very appreciated. Thanks in advance.
Inside a proc:
with a normal hard return within the column alias after "sep=,".
This comment on purple frog indicates you can also use the tab character as a delimiter.
Also looks like this answer's been posted already, my bad: https://stackoverflow.com/a/44315682/5758637
(Copying and pasting in case the purple frog link goes dead in the future):
Adding
with result solved the issue
See Source
Adding
@query_result_separator
should do the trick.Adding
@query_result_no_padding = 1
might clean up the results a bit. All off the arguments can be found here