0

I'm currently attempting to run an update on a table using a linked server

Ex.

update table1 a
set a.column1=(select Count(b.column1) FROM linkedserver.databse.table b)
where a.column2=b.column2
and a.column3=b.column3

My problem is:

The multi-part identifier "linkedserver.databse.table.column" could not be bound.

The only way i can see this working is with aliases and i know the server has the appropriate access to the linked server.

3 Answers 3

1

You need to include the schema in your query

try using

LinkedServer.Database.Schema.Table

Or

LinkedServer.Database..Table   (if schema is dbo)
Sign up to request clarification or add additional context in comments.

Comments

0

Not certain it's the cause of your problem, since I would expect to see a different error, but your syntax should be:

update a
   set a.column1=(select count(b.column1) 
                    from linkedserver.databse.table b
 where a.column2=b.column2
       and a.column3=b.column3)
  from table1 a

Comments

0

Use UPDATE FROM statement and 4 parts table name when you're working with linked servers.

update table1
set column1=(select Count(b.column1) FROM linkedserver.databse.dbo.table b)
from table1 a
where a.column2=b.column2 and a.column3=b.column3

Comments

Your Answer

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.