How to generate Insert Statement in MySQLKedarMay 5, 2010 A lot of places I saw people asking for ways to generate Insert statements. We do have GUI Tool which can extract insert statements for us readily. Some of the… View Post
8 responses to “How to generate Insert Statement in MySQL”
Thanks a ton dude…
enjoy thanks 😉
I also get the error “Create table ‘agps’ failed!
ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘)’ at line 1
CREATE TABLE `agps` ()” when trying to migrate microsoft access to Mysql on an Ubuntu 10.4 pc.
I did not write any SQL so it must be some canned SQL script generated by ESF database migration tools kit. which is causing the error.
I think that the user has all the necessary permissions, but it is almost impossible to tell with mysql.
Could it be that the version of mysql running under Ubuntu has a different language to that assumed by ESF?
I am running ESF on a windows pc accessing the access database on the linux pc on a LAN as there is no linux version as far as I know.
Hey Mike,
I tried the demo version!
I’ve already tried Kettle (the open source product) and ESF Data Migration toolkit (~11K INR) which worked nicely for me.
+Advance ETL costs (16K INR)!
My observations.
Advanced ETL Processor can generate INSERT SQL from any data source including test files
http://www.etl-tools.com/generating-insert-statements.html
Mike
MySQL has a feature for profiling query. By default its off, but you can turn it on per MySQL session by issueing “set profiling=1” on MySQL command prompt.
http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html
But it has some limitation, first of all, it can be used for debugging while you are in a development mode. Second, it can not be used for query logging purpose.
Major limitation it has is, you can also store 15 queries in MySQL profile and it can be configure upto 100 queries.
As you’ve copied the code from above snipped it seems a problem with quotes (‘ and `). Please download file available at the end of the page and give it a try.
Regarding not storing output in a file, just remove the section >> ” INTO OUTFILE ‘”, in_file ,”‘”);” from the query and procedure will output the result on prompt.
Replace “set @Inserts….” line with following:
set @Inserts=concat(“select concat(‘insert into “, in_db,”.”,tablename,” values(‘,concat_ws(‘,’,”,@Sels,”),’);’) from “, in_db,”.”,tablename,” group by “,@Whrs, “;”);
Appreciate your effort. But i am getting the following error using ur SP :
Script line: 4 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’”\’,ifnull(‘,column_name,’,””)’,’,\’”\’)’)) INTO @Sels f’ at line 12
Cannot figure out the problem. And also is there any way to return the Insert statements as return value instead of writing to a text file ? I am new to MySql