Reputation: 1
Well I have read ALOT of posts and I can't quite find the perfect answer to my question, (or I have and havn't realised it!:-))
I have a large csv file that I want to read into my program and sve it to a SQL database table.
I'm useing VB2008 and my dabase is SQL2008.
Any help would be appreciated.
Cheers Cookster
Upvotes: 0
Views: 3899
Reputation: 33484
A simple & fast way would be using TSQL.
BULK INSERT AdventureWorks2008R2.Sales.SalesOrderDetail
FROM 'f:\orders\lineitem.csv'
WITH
(
FIELDTERMINATOR =',',
ROWTERMINATOR =' |\n'
)
For this to work, the CSV file should be accessible to the DB server.
Example modified per your question from here.
The other option is to use SQLBulkCopy
.
EDIT: If you are OK using an external library, FileHelpers can be one of the option.
Upvotes: 1