Friday, October 3, 2008

Creating Update Scripts with DataDude

Often when developing an application there comes the need to create reference data that is stored in the database. This reference data is generally read-only with the occasional insert.

For my example I am going to use a database that supports a leasing application. The current production version of the application contains a table named LeaseType that is used to populated drop-down lists of the different lease types that are available. Currently the application supports two types of leases, “Long Term” and “Short Term”. A new requirement has been introduced that requires two new lease types, “Temporary” and “Extended”.

As the new features for the application are developed a script will need to be written that will insert the two new values into the database. It is possible that there are maintenance screens that are used to update this type of information but for the sake of example we will assume that in this case the data will be scripted with the scripts executed as part of the upgrade.

With Visual Studio Team System Database it is very easy to generate the insert scripts rather than writing them by hand.

A couple of assumptions are being made:

  1. The developer has access to a copy of the production version of the database. I generally prefer to have a version of the production database available on a development server or on the develop workstation to use for testing and comparisons.
  2. A Visual Studio Team System database project has been created.
  3. The new values have been entered into the development database on the local developer workstation.
Rather than writing the insert script you can follow these steps to have it generated for you:

1. Select “New Data Comparison” from the Data -> Data Compare menu in Visual Studio

2. Select your development database as the source and the production version as the destination
3. Choose only the tables to which you have added values and select “Finish"

4. The DataCompare window opens showing you the differences between the two database tables

5. Select the “Export to Editor” button on the Data Compare toolbar


6. Presto, you have the scripts!



1 comments:

Marnie said...

But can you calculate the rate of decreases for an armscye?