﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / how to attach multi queries result to different sheets‎ in same excel / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 02:41:26 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: how to attach multi queries result to different sheets‎ in same excel</title><link>http://www.sqlservercentral.com/Forums/Topic1419306-149-1.aspx</link><description>[quote][b]sandosh.star (2/12/2013)[/b][hr]@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,SGI want to group by country and attach the result in different sheet in same excel fileExample: If AU means all AU data in one sheet and SG means all SG data in another sheetIs it possible?[/quote]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 [i]plain-text[/i] 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.</description><pubDate>Wed, 13 Feb 2013 04:48:27 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>how to attach multi queries result to different sheets‎ in same excel</title><link>http://www.sqlservercentral.com/Forums/Topic1419306-149-1.aspx</link><description>@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,SGI want to group by country and attach the result in different sheet in same excel fileExample: If AU means all AU data in one sheet and SG means all SG data in another sheetIs it possible?</description><pubDate>Tue, 12 Feb 2013 23:36:10 GMT</pubDate><dc:creator>sandosh.star</dc:creator></item></channel></rss>