Question : Insert into from csv file

How do load data via a SQL statement from a comma-separated file into a Sybase Enterprise table?  

I was doing the following in Sybase Anywhere:

"input into TEMP_IMPORT from 'C:\temp\input.csv' format ascii"

I don't think bcp is acceptable because I can't run it as a SQL statement.

Answer : Insert into from csv file


if you are using servlets, i suggest you read the file line by line and insert it into the database.

i assume that the number of columns in each row of the file are equal to that in the physical definition of the table.

say if you entire line is in a variable called $line, you can create an SQL saying
"insert into tablename select $line"

hope it helps. thanks,

Amit.
Random Solutions  
 
programming4us programming4us