views:

41

answers:

3

Are there any .Net libraries that provide a way of exporting sql database data to plain text files (i.e. csv\tsv)? SqlBulkCopy only applies to the import part of the solution and I prefer not to be calling any Process.Start calls to open up command prompts to call bcp.exe.

+1  A: 

As such there is no .net library which you can use for export data into txt/csv. You can use StreamWriter to write data in txt/csv file.

Jeevan Bhatt
A: 

Would calling a stored procedure work for you? I did a quick Google for using bulk copy in a procedure and found this article:

http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/

Tony
A: 

Check out FileHelpers - it allows you to easily load or save data from CSV or other text file formats. Excellent code base, freeware, full C# source available - can't recommend it enough!

marc_s