Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All!

I want to copy a table with data from a database on one server to a database on a second server. The source table will refresh within next 3 min with new data. What is the best way to do this?
Posted

Hi
First Solution:
I think you must define a job for execute bellow query:
SQL
Insert	[ServerName].[DatabaseName].[SchemaName].[TableName]  -- Your Destination
Select	*
	From	[ServerName].[DatabaseName].[SchemaName].[TableName]	As	Sources
	Where	Not Exists	
		(Select	*
			From	[ServerName].[DatabaseName].[SchemaName].[TableName]	As	Destination
			Where	Sources.ID	= Destination.ID)


Second Solution:
But If you want use best way you must use from Merge Replication.
For do this you must define a replication as merge type in SQL Server.
Performance of this way is the best and I think you can trust to Merge Replication SQL Server.

I hope it's helpful for you.
 
Share this answer
 
v2
Comments
Maciej Los 15-Jul-13 16:10pm    
This answer is good if this query would be executed once per month, but not for every 3 minutes ;) For thousands of thousands of data the query won't stop executed before next job.
Please, read question carefully.
Reza Alipour Fard 15-Jul-13 23:13pm    
I update my answer. I add a best way for do this action. Please check my answer.
Maciej Los 16-Jul-13 2:44am    
A 5 for improvement of solution!
SQL Server Replication[^]

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