Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All

I need to synchronise two sql server databases automatically. When some insetion/updation/deletion happens in the particular table of Server database it should be reflected in the client database.How to do that?
I need a sample to synchronise the tables between two databases.





Regards

Bala
Posted
Comments
Teenustar 26-Sep-12 9:32am    
Try learning about SQL server replication.

1 solution

Try this One Hope it will work TSQL

--Syncronize tbl_users2 with tbl_users
SQL
insert into tbl_users2 (UserName,Email)
select UserName,Email  from tbl_users except
select UserName,Email from tbl_users2

-- repeat this process but in reverse order.
--Syncronize  tbl_users with tbl_users2
insert into tlb_users (UserName,Email)
select UserName,Email  from tbl_users2 except
select UserName,Email from tbl_users


--this commands returns all the rows which exist in tbl_users but do not exists
--in tbl_users2
SQL
select UserName,Email  from tbl_users except
select UserName,Email from tbl_users2


SQL
--this commands returns all the rows which exist in tbl_users2 but do not exists
--in tbl_users


SQL
select UserName,Email  from tbl_users2 except
select UserName,Email from tbl_users
 
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