Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DCW87
Starting Member
6 Posts |
Posted - 2012-06-19 : 05:50:49
|
Hey guys,just joined this forum so apologies if this has landed in the wrong place. I'm looking for some T-SQL to autoformat my query results into a .csv style output which can then be used to drive sp_send_dbmail with the file output.As it stands, the email sends the query results fine but its in a format which is a little unfriendly. for example, it returns headers with underlines and then the results are seperated by multiple tabs.Here's the code i have so far:EXEC msdb.dbo.sp_send_dbmail@recipients=N'david.wimbush@email.com',@body= 'This is the email body',@subject = 'This is a test email',@profile_name = 'SQL Mail',@execute_query_database = 'ADCOE',@query ='set nocount ON select * from TABLE_NAME',@query_result_separator= ',',@attach_query_result_as_file = 1;hopefully that makes sense! Thanks in advance,DW |
|
DCW87
Starting Member
6 Posts |
Posted - 2012-06-19 : 06:05:05
|
I know this can be achieved via SSIS but is there anyway to achieve this within managament studio? |
|
|
|
|
|