1

i'm trying to update a remote table using linked server, based on id of my local table.

I'm trying this:

update [HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2
 set [HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2.cod = tabela1.codigo
 from [HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2 
 join tabela1 
 on tabela1.id=[HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2.id

The multi-part identifier "HQSQLHOM01\SQLHOM01.dba_teste.dbo.tabela2.id" could not be bound.

i tried to update the local server based on the linked server but I still receive errors like the TABLE_NAME could not be bound.

update tabela1 
 set tabela1 .cod=[HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2.cod
 from [HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2 
 join tabela1 
 on [HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2.id=tabela1.id

Msg 4104, Level 16, State 1, Line 40 The multi-part identifier "HQSQLHOM01\SQLHOM01.dba_teste.dbo.tabela2.cod" could not be bound.

There's a lot of questions like this one on stackoverflow but none of them is working.

tabela1=local

asked Oct 20, 2016 at 11:12

1 Answer 1

3

You cant have 5 identifiers, this should do the trick

UPDATE T2
SET T2.cod = T1.codigo
FROM [HQSQLHOM01\SQLHOM01].dba_teste.dbo.tabela2 AS T2
JOIN tabela1 AS T1
 ON T1.id = T2.id

https://technet.microsoft.com/en-us/library/ms190406(v=sql.105).aspx

answered Oct 20, 2016 at 11:46
1
  • I just need to use SET XACT_ABORT ON because i'm tyring to use begin tran. Commented Oct 20, 2016 at 12:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.