SQLCMD Archives - Dirk Strauss

Exporting SQL Query Results to a CSV file using SQLCMD and C#

On 8 March, 2013 08:00:44, in Programming, by Dirk Strauss

Command Prompt to run SQLCMDToday a colleague asked me how to export SQL Query Results to a CSV file. This got me thinking that it would be a nice exercise to do this from a C# application.

So to start off, I downloaded the correct AdventureWorks database for my version of SQL from the following CodePlex page.

I attached the database and wrote a short piece of code to execute SQLCMD from C#.

Continue reading »

Tagged with: