0

The scenario is this. I have a SQL Server database online that I am demoing an application. During development, I have added extra fields, modified field types, changed keys and added some new tables locally.

What's the best way for me to update the online database with the new structure and not lose the data? The database is a SQL Server 2005 one.

5 Answers 5

2

Download a trial of Red Gate SQL Compare, compare your two servers and you are done. If you do this often, it is well worth the $400, or get one of their bundles for a better bang for the buck.


And I do not work for Red Gate, just a happy customer!

Sign up to request clarification or add additional context in comments.

Comments

2

Write update scripts to modify your live database structure to the new structure, as well as inserting any data which is required.

You may find it necessary to use temporary tables to do this.

It's probably best if you test this process on a test environment, before running the scripts on the live environment.

Comments

0

Depending on what exactly you've done you may be able to get away with alter statements, though from the sounds of it (removing keys and whatnot) you're doing some heavy lifting that may make that a less-than-ideal solution. You should probably look into creating a maintenance plan or, better yet, a SQL Server Integration Services project in Visual Studio. You should be able to migrate the data in the existing database to a new one using those tools.

Comments

0

This probably isn't of huge help retrospectively, but I always script all structural DB changes to my development database and then using a version number to determine the current version of the DB I can run the required scripts on the live DB, hence bringing it back in line at the same time as the new code is uploaded.

This also works for any content changes, for instance if the change in the underlying structure has an effect on the conent stored you can also write scripts to migrate the data accordingly.

Comments

0
  1. Make a copy of the existing database to copy from.

  2. Make another copy and alter it to your new schema. save DDL for reuse.

  3. Write queries that copy data from #1 to #2. Save the queries for reuse.

  4. Check the results.

  5. Repeat until done.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.