Click here to Skip to main content
15,888,100 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to export my data from SERVER1 to SERVER2. I try to get the latest date and not all the data in the SERVER1. The table I would like to move the table do content XML data type.

What I have tried:

SQL
SELECT * FROM OPENQUERY (SERVER1, 'SELECT  EmployeeID, EmployeeName, JoinDate, CAST([XMLContent] AS NVARCHAR(MAX)) FROM dbo.Computer.tblEmployee WHERE JoinDate=>'23-02-2016'  ')
								
		IF NOT EXISTS 
		(SELECT * FROM OPENQUERY ([SERVER2], 'SELECT  EmployeeID, EmployeeName, JoinDate, CAST([XMLContent] FROM dbo.Computer.tblEmployee'))
		
		BEGIN 
		 
		INSERT INTO dbo.Computer.tblEmployee SELECT * FROM OPENQUERY ([SERVER2], 'SELECT  EmployeeID, EmployeeName, JoinDate, CAST([XML] FROM dbo.Computer.tblEmployee')
		 
		END
Posted
Updated 25-Feb-16 17:23pm
v2

1 solution

Your select statement in the insert statement, is executing query on server 2. Is that intentional? Also, there is no date clause in that statement. Fixing these two things ma solve your problem.
 
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