-2

I am upgrading a website to asp.net which have at least 100K posts in wordpress. I could not find any related topic for moving so i wanted to share my experience.

Big data is not a problem, however, some of wordpress tables have html data containing quotes (both single and double), &nbsp's, tab characters and so on. I have tried many ways for both exporting however, exporting to SQL file will not work for me (at least, i could not able to work with it, it causes so many troubles).

Oğuzhan Kahyaoğlu
  • 1,727
  • 2
  • 15
  • 20

2 Answers2

0

Best way to move data is exporting to CSV files, seperately for each table. While exporting, you have to:

  1. Custom Export
  2. Different and unique strings for both "Columns separated with" and "Columns enclosed with" (I used ############ and @@@@@@@, respectively)
  3. Check "Remove carriage return/line feed characters within columns"
  4. Check "Put columns names in the first row"
  5. Download export file

After downloading, replacing will take place:

  1. Tabs with spaces \t -> space
  2. Double quotes to single " -> '
  3. ###### -> \t
  4. @@@@@@@ -> "

Finally, encoding conversion is required. myadmin output is ANSI file and it is corrupt. Sql server might not able to handle it. To resolve it, first convert to UTF-8 and convert to ANSI again (In notepad++, it has options in "Encoding" menu).

While importing to SQL server, you must have to select text file as source. Select related csv files and while importing, take care of column lengths. Sql server will make all your columns varchar(50) default. Exported data will have much more larger columns. You have to adjust them in import wizard manually. Use DT_Text (not DT_NTEXT) for string values.

I know this process will result in some data loss (tabs and double quotes) however, it is wordpress' html editor's fault. Html data should be stored as encoded in database for these purposes...

Oğuzhan Kahyaoğlu
  • 1,727
  • 2
  • 15
  • 20
0

go with a linked server created on the target system; this way the import process can be driven by SQL-Server and will hopefully produce a result ready to use without requiring too many steps & checks.

there are many SO posts about interacting with MySQL from SQL-Server:
Can't create linked server - sql server and mysql
SELECT * FROM Linked MySQL server
Do I have to use OpenQuery to query a MySQL Linked Server from SQL Server?

Community
  • 1
  • 1
Paolo
  • 2,224
  • 1
  • 15
  • 19