SQL to TXT export batchfile

I needed to export a number of tables from a SQL server to text files today. BCP is great but doesn’t include header information which I needed. With some help from a couple of internet posts I wrote this batch file which worked great. It will take all the tables from a database (edit batch file to specify the database name) and export them to separate pipe delimited files. You can change the delimiter by replacing the two ^| with , if you want comma-delimited. It will also pause after creating the list of tables and open a notepad of all of the tables allowing you to remove any tables that don’t need to be exported (in my case they had a few tables containing binary attachments). Existing files are NOT overwritten allowing you to restart if needed.

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

No comments yet.

Sorry, the comment form is closed at this time.