roman m
roman m

Reputation: 26555

Alternative to SQL BULK INSERT

I need to import the data form .csv file into the database table (MS SQL Server 2005). SQL BULK INSERT seems like a good option, but the problem is that my DB server is not on the same box as my WEB server. This question describes the same issue, however i don't have any control over my DB server, and can't share any folders on it.

I need a way to import my .csv programatically (C#), any ideas?

EDIT: this is a part of a website, where user can populate the table with .csv contents, and this would happen on a weekly basis, if not more often

Upvotes: 4

Views: 11477

Answers (4)

abombss
abombss

Reputation: 476

Try Rhino-ETL, its an open source ETL engine written in C# that can even use BOO for simple ETL scripts so you don't need to compile it all the time.

The code can be found here: https://github.com/hibernating-rhinos/rhino-etl

The guy who wrote it: http://www.ayende.com/blog

The group lists have some discussions about it, I actually added bulk insert for boo scripts a while ago. http://groups.google.com/group/rhino-tools-dev http://groups.google.com/group/rhino-tools-dev/browse_thread/thread/2ecc765c1872df19/d640cd259ed493f1

If you download the code there are several samples, also check the google groups list if you need more help.

Upvotes: 2

roman m
roman m

Reputation: 26555

i ended up using CSV Reader. I saw a reference to it in one of the @Jon Skeet's answers, can't find it again to put the link to it

Upvotes: 1

jason saldo
jason saldo

Reputation: 9950

How big are your datasets? Unless they are very large you can get away with parameterized insert statements. You may want to load to a staging table first for peace of mind or performance reasons.

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351446

You have several options:

  1. SSIS
  2. DTS
  3. custom application

Any of these approaches ought to get the job done. If it is just scratch work it might be best to write a throwaway app in your favorite language just to get the data in. If it needs to be a longer-living solution you may want to look into SSIS or DTS as they are made for this type of situation.

Upvotes: 5

Related Questions