Hacker News new | ask | show | jobs
by sergiosgc 4230 days ago
> First, you can import/export csv's. Hell all you need to do to export, is right click the view and hit export, then select .csv.

Are you saying there is no programatic interface for exporting csv? You must rely on the administration tool to generate the csv for you???

1 comments

@sergiosgc Nope. There are several ways of doing this. Using the GUI is the easiest, and the most common method. You can use SSIS, or the bcp command.

For example:

bcp "SELECT blah... FROM blah" queryout C:\..\blah.csv -c -t, -T –S<servername>

I have spent quite a bit of time in the past trying to import CSV data to SQL Server. It's just about possible, but bcp (and its format files) are absolutely horrifying. As far as I could tell, other methods of importing data involved either having access to put files onto the server so it could read them or getting SSIS to work - both pretty much impossible in a large organisation.
If there was one thing the author was right about it was MSSQL's poor CSV support. BCP doesn't handle escaping special characters in CSV (e.g. commas, quotes, tabs if you using tabs as delimiter).