Jacob L
asked on
Updating data in a remote table by using a linked server
Hi,
I am trying to update a column in one database from a select statement on another database.
lets call database1 = weis1 and is on server1
and database2 = weis2 and is on server2
EXEC sp_addlinkedsrvlogin 'Accounts', 'true'
update server1.weis1 .[dbo].[CAT_RootOrg]
set CAT_RootOrg.SKUCode=999999
From server1.weis1.[dbo].[CAT_R ootOrg] t1
join server2.weis2 .[dbo].[ITEM_MASTER] t2
on t1.upc = t2.upc
where server2.weis2 .[dbo].[ITEM_MASTER].upc=n ull
Sorry i am just a novice at best when comes to sql. Any help on this would be great.
I am trying to update a column in one database from a select statement on another database.
lets call database1 = weis1 and is on server1
and database2 = weis2 and is on server2
EXEC sp_addlinkedsrvlogin 'Accounts', 'true'
update server1.weis1 .[dbo].[CAT_RootOrg]
set CAT_RootOrg.SKUCode=999999
From server1.weis1.[dbo].[CAT_R
join server2.weis2 .[dbo].[ITEM_MASTER] t2
on t1.upc = t2.upc
where server2.weis2 .[dbo].[ITEM_MASTER].upc=n
Sorry i am just a novice at best when comes to sql. Any help on this would be great.
Are you getting any error or what is the issue? The only problem I see assuming the user running it has all necessary rights in place is that it will be very slow on large volumes. Can you create a view on Server2 and filter that data at least right at the source?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks icohan. The problem is more of permissions thing. My DBA will have to run it. but your query above helps a lot. Thanks so much