msfanboy
msfanboy

Reputation: 5291

SQL-Server 2005: The multi-part identifier ... could not be bound.

My error message:

The multi-part identifier table2.ValidSince" could not be bound.

UPDATE table1
SET table1.ValidSince = table2.ValidSince
WHERE table1.ID = '5C954C6F-FFD7-454A-9E2B-000076523819'

How do I need to change the update to make it work?

Upvotes: 2

Views: 4104

Answers (2)

Neil Knight
Neil Knight

Reputation: 48547

You haven't declared table2 anywhere in your statement. You need to include table2 in order to be able to use it.

UPDATE t1 
   SET t1.ValidSince = t2.ValidSince 
  FROM Table1 t1 
  JOIN #Table2 t2 
    ON t1.PKCol = t2.PKCol 
 WHERE t1.ID = '5C954C6F-FFD7-454A-9E2B-000076523819' 

Upvotes: 2

codingbadger
codingbadger

Reputation: 43984

You need to join on to table2

UPDATE t1
SET t1.ValidSince = t2.ValidSince
From Table1 t1
Join Table2 t2 on t1.PKCol = t2.PKCol
WHERE t1.ID = '5C954C6F-FFD7-454A-9E2B-000076523819'

Upvotes: 6

Related Questions