Click here to Skip to main content
11,704,107 members (57,912 online)
Rate this: bad
Please Sign up or sign in to vote.

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 2:43am

1 solution

Rate this: bad
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
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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 745
1 OriginalGriff 520
2 Maciej Los 475
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,784
1 Sergey Alexandrovich Kryukov 7,843
2 CPallini 5,107
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 13 Aug 2012
Copyright © CodeProject, 1999-2015
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