0

I have a custom made CMS system with a relatively small number (~1000) of articles inside my SQL Server database.

I want to migrate the whole site to Wordpress. Is it possible and if so, then how, to migrate the data (one table - Article) from SQL Server to a CSV file and then import it into Wordpress?

Thanks!

update:

The structure of table Article looks like this:

ID_Article - int (pk)
Title - nvarchar(max)
Summary - nvarchar(max)
Contents - nvarchar(max)
Date - datetime
ID_Author - int (fk)
Image - nvarchar(max)
Promoted - bit
Hidden - bit

There also categories done with an associative CategoryToArticle table. The only thing that needs to be moved is CONTENTS (optionally merged with Summary) DATE and TITLE (would be cool if it was merged with author's name "John Doe: My Article title."). It can be categorised as "Archive" or soemthing like that, image and other flags can be dropped completely.

barjed
  • 387
  • 1
  • 5
  • 18

4 Answers4

1

Use the SQLCMD command line tool. You can look at this question to see how to export data into a CSV.

Community
  • 1
  • 1
Neil Knight
  • 47,437
  • 25
  • 129
  • 188
  • Yes but the way I understood Wordpress' CSV importer column names of imported CSV file have to have "appropriate" names. So I guess I would need to change while generating the file. – barjed Jul 15 '11 at 10:47
  • @barjed: Then name the columns eg. `SELECT Col1 AS [Column1]` – Neil Knight Jul 15 '11 at 10:48
1

It is possible. However, it heavily depends on the structure of your current table. If you have tags, categories, different post statuses (published, pending etc).

One possible way would be to write a script to read from your database, and drop the same data into the wordpress tables.

MSSQL -> CSV -> MySQL is also possible. You'll just have to read the CSV and dump the data into MySQL.

Maybe if you can give your table structure, we can give you a better way.

Sterex
  • 1,026
  • 1
  • 13
  • 29
1

this might help you

first create a table in mysql DB

CREATE TABLE Genesis (
    id INT(10),
    title varchar(255),
    description text,
    date timestamp,
    PRIMARY KEY (id)
  ); 

then use some php code to updae wordpress data. source -
http://web-design101.com/createawebsite/featured-articles/insert-wordpress-posts-through-mysql

sjngm
  • 12,423
  • 14
  • 84
  • 114
1

You could use an automation software such as BlogSenseWP to import the CSV items in as new posts, but you would have limited control over the dating and tagging would have to be auto-regenerated using the Yahoo Tags API (included in the software's features). Categorization might be tricky as well, but there are keyword based auto-categorization filters that could help you get close.

Otherwise you would might want to investigate a custom PHP script that imports the CSV fields desired into variables, and then loops through them adding them to the wordpress database using wordpress functions.

Here is a custom way of adding a post to wordpress:

$permalink_name = sanitize_title_with_dashes( $title );
$post = array(      
                              'post_author' => $author_id
                              'post_category' => $cat_id, 
                              'post_content' => $description, 
                              'post_date' => $date_placeholder,
                              'post_date_gmt' => $gmt_date,
                              'post_name' => $permalink_name,
                              'post_status' => 'publish', 
                              'post_title' => $title,
                              'post_type' => 'post',
                              'tags_input' => "$tags",
                              'original_source'=> $link
                            );  
                            $post_id = wp_insert_post( $post, $wp_error );

You would have to include the wp-config.php file at the top of this script to load the wordpress code environment.

The above is a crude summary. It would take a thorough understanding of PHP to fill in the ommited code and complete the concept script.

Hudson Atwell
  • 192
  • 1
  • 4
  • 13