Jump to content

append an .csv or xls file into DB


raviprakashg

Recommended Posts

I have a Problem to append record taken from an table which was taken from online and its in .csv format. what have do is, the records to be appended in my local DB (the both tables has same fields)

So you have a single record in a .csv file that you need to add to a table in a local DB and the table and csv file have the same columns (and same order?).Are you trying to create a process in a program so that this can be done multiple times or do you just want to do it once?Well, if only once, then you can do a regular insert statement and just copy the contents of the .csv file into the Values clause of the statement...something like this:
INSERT INTO table (column names separated by commas)VALUES (contents of .csv file)

If you are trying to create a program to do this multiple times, then you might want to move the contents of the .csv file into a string variable and include the string variable in your statement....although you will have to ask someone else how to do that....all I write are ad-hoc queries in SQL. I have not branched out to workign with SQL through other languages such as VB, ASP, PHP, etc.And if you are wanting to add more than one record at a time, then you will need to do it programmatically probably and just grab one row at a time into a string variable.Well, hope this helps you at least get started.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...