Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to attach multi queries result to different sheets‎ in same excel Expand / Collapse
Author
Message
Posted Tuesday, February 12, 2013 11:36 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 1, 2013 7:40 AM
Points: 5, Visits: 22
@subject ='Status Log for Today'
,@profile_name ='Status'
,@query ='my query'

,@attach_query_result_as_file = 1
,@query_attachment_filename ='Status.csv'




output has Column name called COUNTRY contain different countries AU,MY,SG

I want to group by country and attach the result in different sheet in same excel file



Example: If AU means all AU data in one sheet and SG means all SG data in another sheet

Is it possible?
Post #1419306
Posted Wednesday, February 13, 2013 4:48 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 8:51 PM
Points: 7,125, Visits: 12,723
sandosh.star (2/12/2013)
@subject ='Status Log for Today'
,@profile_name ='Status'
,@query ='my query'

,@attach_query_result_as_file = 1
,@query_attachment_filename ='Status.csv'




output has Column name called COUNTRY contain different countries AU,MY,SG

I want to group by country and attach the result in different sheet in same excel file



Example: If AU means all AU data in one sheet and SG means all SG data in another sheet

Is it possible?

No, for multiple reasons. 1) a CSV file and an Excel file are two different things. While a file with a .csv extension may open in Excel by default because of a Windows setting on somone's workstation it does not make that file an Excel-formatted file. A CSV file is merely a special form of a plain-text file and cannot have "Tabs". 2) msdb.dbo.sp_send_dbmail cannot generate Excel files. It can generate text files with whatever name, extension and delimiter you like, but not Excel-formatted files. 3) msdb.dbo.sp_send_dbmail can only execute one query and push all the results from that query into a text file.

If you must generate an Excel-formatted file by issuing multiple queries and pushing each result into a separate Worksheet within an Excel Workbook then you could look into using SSIS.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1419399
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse