Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 

IS their any way to generate an alter script of a table, of two different versions.
 
If we have a table T1 in Database Dv1, an extra column is added in T1 and the database is named as Dv2.
 
Then i want to generate an alter script of that extra column.
 
Using SMO,I could generate scripts of the tables but, how can i compare these two tables and generate the alter script.
 
Do any one have an idea proceed.
 
Using SQL SERVER 2008 and C#/VB
Posted 13-Aug-12 3:43am
rok_007577

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There are 3 easy ways to do it, 2 are free, but require discipline
 
1. At every 'epoch', dump all the create files, run winmerge, or similar, over them and create the alters manually
2. Mandate that all changes to DB structure are done with alter scripts, and simply collect and coalesce them
3. use something like Redgate's sqlcompare [^]
 
I'd personally recommend #2 - I have used Sql Compare, and bluntly, it's brilliant, but #2 gives you traceability
  Permalink  
v2
Comments
rakesh_d at 14-Aug-12 9:28am
   
Thank you barneyman for reply..
 
I could generate Create script, and compare the two version script as Redgate provides.
 
But my concern is to automate the generation of alter script comparing the two DB versions.
 
please let me know any possible ways to build it...
barneyman at 14-Aug-12 19:11pm
   
i don't know of a way, apart from Redgate
rakesh_d at 15-Aug-12 8:41am
   
Thank you barneyman

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 13 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100