Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two database Database1 and database2
and this two database have two tables
table1 and table 2

table1 is database1 table
and
table2 is database2 table


this two tables having same columns

i want to update Database1 table1 to database2 table2


any one help me...
Posted

Quote:
i want to update Database1 table1 to database2 table2

Check Solutions:
Update records from One database to another database[^]
 
Share this answer
 
Using `MERGE` would be an ideal way to insert/update when the data present in two different databases.

Sample:

SQL
MERGE INTO Destination_Table AS Dest
USING Source_Table AS Source
ON Dest.ID = Source.ID

WHEN MATCHED THEN 
UPDATE Dest SET Dest.EmpName = Source.Empname,
                Dest.Empdept = Source.Empdept    
WHEN NOT MATCHED THEN 
INSERT VALUES(
                Source.ID
               ,Source.EmpName
               ,Source.Empdept);
 
Share this answer
 
v2

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