T-SQL Updating values from another database in another server

Pho3nix

The Legend
Joined
Jul 31, 2009
Messages
32,826
Reaction score
3,033
Location
On the toilet
Hi,

Need some assistance with doing this.
Syntax doesn't look or work right :(

Code:
Update CD.live.User U
SET U.StartDate = r.startdate
from Sserver2.databaseName.dbo.UserTable R

Login details for servers are different and my mind is drawing a blank at the moment :(
 
Try:

Update U with(updlock)
SET
U.StartDate = R.startdate
from
CD.live.User U INNER JOIN
Sserver2.databaseName.dbo.UserTable R ON
(U.TheKey = R.TheKey)


Make sure you join on the pk/key/id of the tables.
 
Still wasn't working. Ended up just copying over the result set I wanted to use to DB1 using an excel sheet and doing the update that way.
Had a similar situation at a client a while back. Used DTS to migrate all data from one server to the target server, then executed my migration script.
Worked like a bomb.
 
Top
Sign up to the MyBroadband newsletter
X