Archive for October, 2008

Migrating from WordPress.com

I had initially set up this blog on WordPress.com to kick the tires and understand how WordPress worked etc. Once I was comfortable with it, I decided to host my blog at this domain. I would recommend this approach for all new bloggers-to-be out there.

When I searched for “migrate wordpress”, I got a lot of results that talked about downloading plugins that can backup\restore your blog etc. But if your blog is hosted on wordpress.com they are of no use.

So, you have set up your blog at xyzblogname.wordpress.com, written a few posts, tried a few different themes, test-driven a handful plugins and now you’re all set to take off the training wheels.  You have secured the www.xyzblogname.com domain name and installed WordPress and are ready to migrate your blog to its new home.

1. Log in to your WordPress.com blog: www.xyzblogname.wordpress.com\wp-admin\

2. Click on Manage and then Export.

3. Select ‘All Authors’ in the Restrict Author drop-down.

4. Click on Download Export File.

5. Save the xml file somewhere on your computer.

6. Login to the Admin console of your new blog at www.xyzblogname.com/wp-admin/

7. Click on Manage and then Import.

8. From the list of systems, click on WordPress.

9. Click on Browse to select the xml file you saved on Step 5.

10. Click on Upload File and Import and let WordPress handle the rest.

You’re all set!

Truncate all tables in a SQL database

This is a handy script that I use regularly. You may wonder why I need to truncate all my tables so frequently but that’s a different story.

When I was searching for this script, almost all results had the ‘exec’ command in the loop to truncate the tables as it looped through each. But I modified it slightly and have replaced the ‘exec’ with the ‘print’ command. What I would like the script to do is generate truncate statements for each table which I can review and in case I want to remove a few tables from it, I can comment them out and execute the rest of the block.

So here we go:

————————————————————————

DECLARE @tableName VARCHAR(1024)
DECLARE table_cur CURSOR FOR 
SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ‘BASE TABLE’

OPEN table_cur

FETCH NEXT FROM table_cur INTO @tableName

WHILE @@FETCH_STATUS = 0
BEGIN
PRINT (‘TRUNCATE TABLE ‘+ @tableName)
FETCH NEXT FROM table_cur INTO @tableName
END

CLOSE table_cur
DEALLOCATE table_Cur

————————————————————————

Please feel free to chime in with any suggestions\recommendations!