Updating changes from one database to another database on the same server

I have a copy of a client database that says "DBCopy" which already contains the changed data. The client database copy (DBCopy) is attached to the SQL Server where the Central Database (DBCentral) exists. Then I want to update all changes already present in DBCopy for DBCentral. Both DBCopy and DBCentral have the same schema. How can I do this programmatically using C # .NET, perhaps by clicking a button. Can you give me some sample code on how to do this? I am using SQL Server 2005 Standard Edition and VS 2008 SP1.

In a real-world scenario, there are about 7 client databases with the same schema as the central database. I bring a copy of each client database and attach it to a central server where the central database resides and am trying to update the changes present in each copy of the client database to the central database one at a time programmatically using C # .NET. Clients and the central server are physically separate machines, present in different locations. They are not related.

I only need to update and insert new data. I am not worried about deleting data.

Thank you and welcome Pavan

+2


a source to share


4 answers


Go to Sync Framework . Otherwise, create some SSIS packages and run them.



0


a source


What you are describing sounds a lot like Database Mirroring .



0


a source


If it's a one-time or infrequent sync, I would use a third-party tool like Red-Gate SQL Data Compare. If this is meant as always synchronization, then I would recommend replication or the Synchronization Framework .

0


a source


I think this is what you need: -----

    USE DB1
UPDATE DB1.dbo.MyTable
SET
  Field1 = d2.Field1,
  Field2 = d2.Field2,
  Field3 = d2.Field3
FROM DB2.dbo.MyTable d2
WHERE d2.MyKey = MyTable.MyKey

      

0


a source







All Articles