Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Update 2 databases with 1 script

By Rich Yarger,

This script was developed to manage a pair of databases that were basically the same, but very different in the schema/metadata content. Unfortunately - they both had the same database name, and were in 2 very specific areas (our main SQL Server and a bunch of hardware devices that were running a very watered down version of the database on Embedded Windows, which is basically WinXP and SQL Server 2005 Express). The environment as a whole is on SQL Server 2005 with SP3 (at the time of this offering, SP4 had not been tested for this project, and thus was not a part of any field/dev test).

 

So essentially - the script works as follows:

 

- Each section of the UPDATE script has 2 areas. 1 for one database and 1 for the other (specified with the values of 'c%' and 't%' in my example.

 

- Simply add in your DDL/DML updates in a specific VERSION section that you would like to have identified for that release.

 

- Whether or not a VERSION release area has content in it or not, your database is going to claim to have received that update. In my example you see 2 sections. This was done for demonstrating how easy it is to simply add another VERSION section, and the logic needed in each.

 

Please feel free to modify this as you like to make it work specifically for you, as well as better for best coding practices/logic.

 

I want to thank both Pam Brisjar and Geoff Russell for thier assistance in getting the logic for this put together, correctly.

 

 

* * * * *EDIT* * * * *

I unfortunately did not properly include the 2 tables and 1 DML trigger needed for this script to work. Please see the discussion section for those DDL pieces. Thanks, and my apologies.

Total article views: 2104 | Views in the last 30 days: 11
 
Related Articles
FORUM

Versioning database release and permission scripts

How do you version permission scripts

BLOG

Restoring a database from higher version to lower version SQL server

Restoring a database from higher version to lower version SQL server How to downgrade a database fr...

SCRIPT

Generate Restore script for multiple databases

Restore script for moving databases from prod to dev with different path / logical name etc.

FORUM

Database Versioning

Stored Procedrue and Tables versioning

FORUM

implementSQL Database version control..

How to implementSQL Database version control..?

Tags
ddl    
dml    
sql server 2005    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones