Hi, I would like to create a script that I can run against any database (call it the *source* database). What it would do is look through all tables and Stored procedures and generate a new script (let's call it DBMaint) that would re-create the *source* database completely. However, I'd like to be able to run DBMaint against an existing *destination* database which may already contain some or all of the tables and or fields (or be completely empty). The logic for each table (and each field within each table) would be:
The idea being that I can setup my dev database correctly with new fields or with some fields removed etc. for the next release of my application (this would be the *source* database), then I can run the main script against the *source* database to generate the DBMaint script. Then this can be run against the live database (this would be the *destination* database) at the time that the application version is released to live. Hope this makes sense!
My main question is: Before I start work on this, is there something out there that does this already? Thanks,
Tom
Code:
If Table doesn't exist then create table
If Field doesn't exist then create field
If Field [b][i]does[/i][/b] exist then check it is of correct size/attributes - if not then change size/attributes accordingly
Delete any fields or tables in the *destination* database that weren't in the *source* database
The idea being that I can setup my dev database correctly with new fields or with some fields removed etc. for the next release of my application (this would be the *source* database), then I can run the main script against the *source* database to generate the DBMaint script. Then this can be run against the live database (this would be the *destination* database) at the time that the application version is released to live. Hope this makes sense!
My main question is: Before I start work on this, is there something out there that does this already? Thanks,
Tom