Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

Database Script Generator

1.92/5 (7 votes)
9 Oct 20061 min read 1   1.2K  
This utility can be used to compare two MS Access databases for changes in the data. You have the option of generating the SQL scripts andor a summary XML

Sample Image - DatabaseScripting.jpg

Introduction

I created this utility for quickly generating the SQL scripts for the changes made to the database. Afterwards, I also added the option to generate the XML which can then be consumed by any application.<o:p>

Mostly we use Access databases for storing the configuration or other information. I came across such situation where I had to change the database. Then to keep track of the changes we use the SQL scripts. To speed up the process I created this utility.<o:p>

Since, I had not used C# before; I developed this utility using C#. So, you may find many issues with the code. But at the end it serves the purpose :-)<o:p>

Also, currently this utility only generates scripts\XML for data changes and not the schema changes.<o:p>

Steps to use:<o:p>

  1. Launch the application <o:p>
  2. Specify the old and new databases <o:p>
  3. Select 'Scripting Options' i.e. whether you want to generate SQL scripts and\or XML file <o:p>
  4. Select the changes you need to consider i.e. rows inserted\deleted\updated <o:p>
  5. In case some tables don't have primary keys you can specify the fields that will uniquely identify the rows using PrimaryKeys.xml. This must be in the same folder as the DatabaseScriptGenerator.exe. (The template is included in the src) <o:p>
  6. The output files will be generated in the same folder as DatabaseScriptGenerator.exe<o:p>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here