Just a quick SQL tip that I have been using recently, and is aimed mainly at MS SQL, but I cant see any reason why this wouldn’t work on MY SQL, except for the fact the MY SQL has easier Backup facilities.

The background for this is that I was making changes to a table, but wanted a backup of the latest version. Microsoft make it ridiculously complicated to backup individual tables and restore them, and I didn’t have time to be reading manuals or trying out third party software.

The script below simple takes the entire table selected and copies it under a new name, giving you both tables to compare and rename/restore as ease.

SELECT *
INTO newTable
FROM oldTable 

I have since used this script several times and seems an easy way of making sure you don’t ruin a perfectly good table!

Join the conversation...

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.