How to update production tables with the changes in the development tables?

  • I have a production database that is currently in use and a development database where users add their records into tables. What's the best way to merge those new / updated / deleted records into production tables? I cannot just delete records, I have to merge them since there could be other changes in prod that are not in dev currently..

  • There are tools that can do that for you, like Data Compare (RedGate) or SQLDiff (ApexSQL).

    Otherwise, you're going to have to write a query that compares the data in the two tables and then build the business rules into the query.

    I have to admit, I'm not sure I understand why user data would be in your dev database and would need to be merged into production. Usually, dev databases are just where you build new/modified code and tables.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • If you aren't already, I'd strongly suggest you start treating the database just like your code. Get it into source control and only do your builds & deployments from there (and the tools Gus suggested will work). You need to know what you're rolling out, just not accept the differences blindly.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply