0

I want to create multiple excel files with data from unique query results in SQL server table.

Basically I will be creating 52 excel file with data in it

Query will be :

select * from customers where country = 'USA'

I want to export customer data for 52 countries into 52 Excel files in one go.

Are there any way to do this by running a stored procedure or function in SQL Server? Your help will be much appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mmoinudd
  • 19
  • 4
  • 3
    I would start [with this answer](http://stackoverflow.com/a/7390928/425809). From there, multiplex it out 52 times (or use a cursor and a loop). – Richard Jun 14 '13 at 19:27
  • I like that, MS SQL server can't export to a simple CSV text file! I just checked the docs http://msdn.microsoft.com/en-US/library/ms190312%28v=sql.90%29.aspx and the backups read as though they are in sql format, or copies of the logs. You may be able to perform this in the opposite direction also, Open Excel and connect to your db from it, using its data source name. – DaveM Jun 14 '13 at 19:48

0 Answers0