Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to compare two databases, first schema and then data.
I can do this manually using Microsoft Visual Studio Data Compare and Schema Compare options, I want to write a code which will do this and provide me with the exact target database as source, given input two databases, connection string, etc, etc; the operation has to be perform on existing database.
Posted
Comments
Sergey Alexandrovich Kryukov 29-Oct-14 2:01am    
Not clear. First of all, you did not define the concept "difference". Actually, this is going to be the hardest part. By some reason, you probably think this is obvious, but it is not.
—SA
Member 10763717 29-Oct-14 2:33am    
By Schema Difference I meant: 1. Added Columns, indices, contraints, etc in tables.
2. Newly added storeprocs
3. Newly added views and tables.
By Data Difference I meant: The rows which are present in Source DB and not in Target DB.
Sergey Alexandrovich Kryukov 29-Oct-14 2:39am    
You are not getting it. There are two variants of schema. There is no information on what is "added" or "removed". Schema does not store its history. The are just different. The question is: what is "difference"? You don't know.
Same thing is about data. If schema is different, how can you tell that some row in one database is the same row as some other row in another database? You don't know.
In a way, you did not realize what you really want. And you did not realize how hard to understand what you want.
—SA

If you intend to use it in production then you can't as that functionality is built into Visual Studio and you can't "use it in your code".

There are a multitude of commercial products for schema comparison like : http://www.red-gate.com/products/sql-development/sql-compare/[^]
 
Share this answer
 

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