Sunday, February 17, 2013 12:46 AM
Hi to everybody
How can I export all tables of a database to one excel file (each table should be one spreadsheet in the excel file) by using SQL Code?
- The export should be generated via (T-)SQL Code not else how- The Excel File should be created by SQL Code (it does not exist in advance)
- The tablenames are dynamic; I don't know the names in advance. Therefore the skript should dynamically read table names (using something like a for-loop)
- I am using SQL Server 2008 R2
- I am using MS Office 2007
Thanks a lot for your support in advance
Sunday, February 17, 2013 9:37 AMHi Angeline,
You can find detailed description here
Sunday, February 17, 2013 10:43 AM
Sunday, February 17, 2013 12:29 PMModerator
>The export should be generated via (T-)SQL Code
There is no T-SQL command for that.
Best to use the SSIS Import/Export Wizard:
Kalman Toth Database & OLAP Architect
Paperback / Kindle: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012
- Proposed As Answer by Rogge Tuesday, February 19, 2013 6:19 PM
Sunday, February 17, 2013 2:22 PM
Basically you will have to write the sql query on all the tables which you want to export, there is no inbuilt way
here is the example with PowerShell how you can export your sql query in excel. check this link
Mark this post as answer if this resolves your issue.
Everything about SQL Server | Experience inside SQL Server -Mohammad Nizamuddin