Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I need to fetch the data from one server DB to other server DB.

I am thinking of using the following merge statement to copy data from one server to other when a row is inserted.(Since i cannot use triggers)

SQL
Merge into  tbl3 as tab2
using(select * from Tbl1) as tab1
      on tab1.id=tab2.id
when not matched then
      insert values(tab1.id, tab1.Name, tab1.Country);




but this works fine in single database.

Please help me to fetch latest row from one server to other using stored procedure
Posted

1 solution

See the following topic in the SQL Server Help file:
* OPENDATASOURCE (Transact-SQL)

Example:
SQL
SELECT * FROM 
OPENDATASOURCE(
'SQLNCLI','Data Source=London\Payroll;Integrated Security=SSPI'
).AdventureWorks2012.HumanResources.Employee


Also see documentation for:
* sp_addlinkedserver (Transact-SQL)
* sp_serveroption (Transact-SQL)
 
Share this answer
 
v2
Comments
phil.o 12-Nov-13 10:52am    
My 5 :)

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