HOWTO load mysqldump into ms sql


the best way to create new dump file from mysql database without extended inserts and locks with command

> mysqldump --no-create-info --extended-insert=FALSE --skip-add-locks --single-transaction

If you have already existing SQL file created by mysqldump, it contains by default extended inserts.
You can try following perl script to reformat SQL queries.
>  mysqldum2mssql.pl  mysql_dump.sql  > mssql_dump.sql
#!/usr/bin/perl # MySQL dump was created as # >mysqldump -u USER -p  --no-create-info --extended-insert DB_NAME > mysql_dump.sql while(<>){  if(/^(INSERT INTO .*? VALUES)(.*)$/i){    my $insert_into_table = $1;    my $values = $2;    $insert_into_table =~ s/`//g;        (my $table_name = $insert_into_table) =~ m/INSERT INTO (.*?) VALUES/;          my @arr_values = $values =~  m{         \(                  # opening (          (                  # Start capture             (?:             # non-capturing group                 [^()']+     # ignore inner brackets              |  '[^']*'     # skip all between single quotes             )*              # and repeat          )          \)                  # final )        }gx        ;        foreach(@arr_values){         print "$insert_into_table ($_);\n";         print "GO\n";    }  } } 1;
The resulting SQL file contains single insert per line and GO after each line. The file can be loaded into MSSQL compact edition (CE) with utility SqlCeCmd40

Enjoy!

No comments:

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.