April 28, 2010 at 2:27 am
Dear All,
I'm relatively new to SQL and need some assistance. Currently I am working on generating reports that are sent via SQL email as a CSV attachment. All was working correctly until I added in 4 more columns. Now the last 3 column headers appear in the wrong columns, below the first 3 column headers (Shifted to the right). However the data is in the displayed in the correct columns. Please see the code below. Where am I going wrong?
msdb.dbo.sp_send_dbmail
@profile_name ='SQL02_Test',
@recipients = 'm_b_hallsworth@hotmail.com',
@body='Query Results Are Attached',
@subject ='Automated Email Test',
@query ='Use Pheonix
SELECT Customer, [Reference Number], [Site ID], [Intervention Type], [Date Registered], [Time Registered], [Item Code], [Item Description], [Faulty S/N],
[Fault Description], [Manufacture Date], [In Warranty], [Replacement S/N], OOB, [Customer Ref], [Deliverery Date], [Delivery Time], [UK TAT],[Repair Despatch Date],[Repair Return Date],[Repair TAT],Status
FROM dbo.Test_Repair_View
UNION
SELECT Customer, [Reference Number], [Site ID], [Intervention Type], [Date Registered], [Time Registered], [Item Code], [Item Description], [Faulty S/N],
[Fault Description], [Manufacture Date], [In Warranty], [Replacement S/N], OOB, [Customer Ref], [Deliverery Date], [Delivery Time], [UK TAT],[Repair Despatch Date],[Repair Return Date],[Repair TAT],Status
FROM dbo.Test_Engineer_Callout_View',
@attach_query_result_as_file = 1,
@query_result_separator ='',
@query_result_no_padding = 1,
@query_attachment_filename ='Test_Report.xls'[/font]
Thanks in advance
Mark
April 29, 2010 at 9:50 am
Problem solved by increasing the result width using the "@query_result_width = " command.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply