1

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.
  • 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
1

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.

  • 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 Shah 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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