Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a data table to SQL server 1

Status
Not open for further replies.

stevet26

Programmer
Feb 9, 2005
53
Hi

A project I am working on right now requires me to write a piece of code which imports the data from a CSV file into a SQL server Database.

Now, the way I see it I have one of two options.

1. I loop through each row of the CSV file and have an insert statement for each one.

2. I loop through each row of the CSV file and build up a data table. Then, once built, I some how insert the contents of the data table into the corresponding table in the SQL server Database.

The second option would be the most effective but I am not sure of how to go about or if it is even possible.

Can anyone tell me if I am on the right tacks and if so point me in the direction of a page which can help me in my quest.

Thanking you all in advance.
 
Hi

I wish ;)

The table in the database has additional fields which need to be populated as the clients CSV file does not contain them.

So I have to run the CSV records through a function to do all of this. Hence why I am creating a data table.

This is a complete pain, I know. But the clients cannot provide me with the data I need.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top