Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a database xyz and 100+ tables and has to perform the following operations on the command line:

  1. I need to create CSV of all tables in one go.
  2. CSV with column separator ,, fields enclosed by " " and lines terminated by \n.
  3. Restore the all created CSV in one go.
share|improve this question
To be clear, you're talking about importing/exporting the contents of the tables, right? – Jon Seigel Mar 13 '13 at 14:19
yes..records of table. – JP Chauhan Mar 13 '13 at 14:20
Okay. Which methods have you tried so far? – Jon Seigel Mar 13 '13 at 14:22
I have tried SQLCMD and BCP. But unable to pick fields enclosed by "". I can create the txt flat files enclosed by "" with the help of Import and Export tool using text delimiter, but this has to do one by one. – JP Chauhan Mar 13 '13 at 14:26

Based on your need, I can suggest couple of options :

  • Use SSIS Import/Export; or
  • Use BCP OUT and BCP IN

Each method has its own benefits and it all depends on your requirement which one to choose.

share|improve this answer
Using SSIS Import/Export is good to generate CSV but I need to create all csvs in one sort and fields enclosed by "".Even BCP has no any option to fields enclosed by "". – JP Chauhan Mar 14 '13 at 5:09
Can I ask -- what are your trying to achieve by creating CSV's for entire database ? Are you trying to generate csvs per table ? Let us know as your requirement is vague to me ... – Kin Mar 14 '13 at 14:31
trying to generate CSVs per table. My main concern is to generate CSVs that has fields enclosed by " ". – JP Chauhan Mar 19 '13 at 6:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.