[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Update Tabale Colum fron another sql instance

I have a server in 1 location: server\instance
this instance has a table:  table1
table has a colum: colum1

I have another server in location 2 with the same instance name and database structure but one of the colums does not replicate from location 1 to location 2.

what sql query would I use to replicate specific colum from location 1 server into location 2 server?
0
intellie_ex
Asked:
intellie_ex
  • 3
  • 2
1 Solution
 
adatheladCommented:
Hi,

First you need to add location 1's db server as a linked server on location 2.
See (e.g.):
http://msdn2.microsoft.com/en-us/library/aa213778(SQL.80).aspx

Then, on location 2 this query will update Table1 Column1 with the data from location 1. Note the extra prefix in the table name ([Server].[Database].[dbo].[TableName])

UPDATE t1
SET t1.c1 = t2.c1
FROM Table1 t1
    JOIN [Location1Server\Instance].DatabaseName.dbo.Table1 t2 ON t1.PKField = t2.PKField
0
 
intellie_exAuthor Commented:
H Adathelad,

I added this question very late last night and might of missed some detail.

In table location 2 under this table, I always have new data but I only want this query to take specific rows where one of the colums has 8356 in it.  The rest of the colums I do not want.
0
 
adatheladCommented:
UPDATE t1
SET t1.c1 = t2.c1
FROM Table1 t1
    JOIN [Location1Server\Instance].DatabaseName.dbo.Table1 t2 ON t1.PKField = t2.PKField
WHERE t2.YourOtherColumn = 8356
0
 
intellie_exAuthor Commented:
I linked the server but getting error:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'RPT_ITM_D'.
0
 
intellie_exAuthor Commented:
I need a query that will look at table in location 2 and only take rows that have 8653 in them and update the table in location 1.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now