Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

1 solution

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
 
Share this answer
 
v2
Comments
rok_007 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 14-Aug-12 19:11pm    
i don't know of a way, apart from Redgate
rok_007 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900