Importing CSV files [C#/Delphi/SQL Server]
On a project that I was recently working on, I was faced with the task of having to import CSV files into an SQL Server database. Just before starting off on writing a custom class to import from CSV, I stumble across a simple way of importing data directly into SQL Server:
SELECT *
INTO theImportTable
FROM
OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};DEFAULTDIR=D:\;Extensions=CSV;',
'SELECT * FROM CSVFile.csv')