How can I generate sql inserts from pipe delimited data?
- by user568866
Given a set of delimited data in the following format:
1|Star Wars: Episode IV - A New Hope|1977|Action,Sci-Fi|George Lucas
2|Titanic|1997|Drama,History,Romance|James Cameron
How can I generate sql insert statements in this format?
insert into table
values(1,"Star Wars: Episode IV - A New Hope",1977","Action,Sci-Fi","George Lucas",0);
insert into table
values(2,"Titanic",1997,"Drama,History,Romance","James Cameron",0);
To simplify the problem, let's allow for a parameter to tell which
columns are text or numeric. (e.g. 0,1,0,1,1)