SQL Server - Custom Export to Excel.. break up data into separate sheets

JElster used Ask the Experts™
I need to export a CUSTOMER table to excel.
But I need to have separate Excel sheets for each Customer STATE.
How can I export the Customer table and break it up in Excel by the STATE field?
I need to do this in SQL Server or a stored procedure. NOT C# or VB code.
thanks in advance.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
When you export to an Excel file you can look at it like a database and to its sheets, if more than one, as tables. So basically you what you need to do is to create an Excel file called Customers with a sheet for each state, you can name it with the states names, and create the structure the same. After that you can use a SSIS to connect and to export to Excel:


One you export the data you will have to create a transaction or flow to each sheet(state) as destination in the excel file and as source you will have to specify the same table(query) but filtered by the state for the corresponding sheet.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial