Batch script to export sql server database to excel

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ganesh kandi
Posts: 1
Joined: 05 Apr 2018 05:24

Batch script to export sql server database to excel

#1 Post by ganesh kandi » 05 Apr 2018 05:47

Hello all,

I have a requirement to export entire SQL server database with a number of tables to an excel file and all the table data need to be exported as different sheets of an excel. So please help me in this.

Thanks in Advance
Ganesh Kandi.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Batch script to export sql server database to excel

#2 Post by Squashman » 05 Apr 2018 08:06

This really has nothing to do with Batch files other than I would assume you could execute your sql query from the batch file itself. I don't know how many SQL experts we have here but I don't know how we are supposed to help you because you have not provided any technical information to your problem.

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: Batch script to export sql server database to excel

#3 Post by SIMMS7400 » 08 Apr 2018 11:36

What you would need to do would be leverage SQLCMD or SQLPLUS from batch to export your tables to a csv file. Then from there, leverage a VB Script (called from batch [CSCRIPT]) to copy that content from the csv file to the specified sheet in your excel workbook.

Very easy to do. Take a crack at it and post your results and then we can step in and assist.

Thanks.

Post Reply