Click here to Skip to main content
14,301,527 members

How to Compare Database Schema in VS 2012, How to Update the Target Database to the Server

Rate this:
5.00 (1 vote)
Please Sign up or sign in to vote.
5.00 (1 vote)
4 Mar 2013CPOL
How to compare database schema in VS 2012 and how to update the target database to the server


In this article, we will discuss how to compare two database schema step by step and finally how to update the target database to the server.


Many times, we come across situations where there are multiple databases used for development and they are to be brought in sync when the development changes are to be moved to QA/production.

Schema compare tool makes it easy to identify the inconsistencies between the databases. The tool not only highlights the attributes that were modified, but also the exact lines of code that were modified/updated.

Using the Code

Let us open the VS2012 IDE, Go to SQL -> Schema Compare -> New Schema Comparison to open the Schema comparison wizard.

The schema compare takes two inputs:

  • Source: The DB where the changes have already been made and from where the modifications are to be rolled out [usually development DB]
  • Target: The DB that is outdated and where the changes are to be made [usually the production or QA database]

Click to enlarge image

Once we have selected the source, target DB. Click on Compare.

Now we can see the changes in the procedures, schema, table are grouped under Change, and the new added tables, procedures are grouped under Add.

Click to enlarge image

Now once we click on any change, we can see the SQL query changes in the object definitions. Changes are highlighted in different color. We can copy/paste modify the query as we want in the target database.

Whereas in add type, we can click on add symbol. Once you have updated the target script, click on update. A pop up will be shown as below:

Click to enlarge image

Once you click on yes, all changes will be reflected in target DB. Now you can view the script, progress, message as shown in the below image:

Click to enlarge image

Points of Interest

There have been lots of changes when compared to VS2010 schema compare on UI side as well as functionality side, most of it being user friendly.


  • 04 March 2013: First version


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


About the Author

Syed Moula Ali
Software Developer
India India
I Started my Programming career with C#. Later got a chance to develop Windows Form applications using C#. Now using C#, WCF, TFS, Entity Framework & Silverlight 5.0 to develop an application, for tagging finance data and generate XBRL files.

My interests involves Azure, ASP.NET SPA, SQL Server 2012, .Net 4.5.

Comments and Discussions

QuestionHow best to compare db schemas of multiple DBs in prod environment? Pin
chauey16-Sep-13 19:47
memberchauey16-Sep-13 19:47 
AnswerRe: How best to compare db schemas of multiple DBs in prod environment? Pin
Syed Moula Ali16-Sep-13 20:21
memberSyed Moula Ali16-Sep-13 20:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 4 Mar 2013


5 bookmarked