Can somebody give me the basic syntax to perform SELECT/UPDATE statements across servers???
Verbiage:
The ultimate purpose is to update a remote DB with all information that is later than what is currently there. I want to:
1. SELECT the MAX value from the remote DB
2. Perform an INSERT with data from the local DB into the remote DB using that MAX value in the WHERE clause
Code:
Ideas or suggestions greatly appreciated!
Verbiage:
The ultimate purpose is to update a remote DB with all information that is later than what is currently there. I want to:
1. SELECT the MAX value from the remote DB
2. Perform an INSERT with data from the local DB into the remote DB using that MAX value in the WHERE clause
Code:
Code:
DECLARE @MaxValue int
/***********************************************
** Grab value from remote server
***********************************************/
SELECT @MaxValue = (
SELECT MAX(RemoteServer.Table1.FieldName)
FROM RemoteServer.Table1
/***********************************************
** Use value to perform a select from local table
** and insert into remote table
***********************************************/
INSERT INTO RemoteServer.Table1
SELECT *
FROM Table1
WHERE Table1.FieldName > @MaxValue
Ideas or suggestions greatly appreciated!