redned
redned

Reputation: 301

Update with Select and Join across tables - "The multi-part identifier could not be bound"

UPDATE
    TrackerNew.dbo.UnitCoreDetails 
SET
    [TrackerNew].[dbo].[UnitCoreDetails].Customer = [Tracker].[dbo].[UnitCoreDetails].Customer

FROM
    Tracker.dbo.UnitCoreDetails s
INNER JOIN
    [TrackerNew].[dbo].[UnitCoreDetails] i
ON
    i.[Serial] = s.[Serial]

This query results in the above error.

I thought it may be an alias problem but it does not seem to be, I have assigned aliases in the join and from clauses. Can anyone help?

Upvotes: 0

Views: 67

Answers (1)

Brett Schneider
Brett Schneider

Reputation: 4103

you do not want to fully qualify the column that you are updating:

UPDATE
    i 
SET
    Customer = s.Customer
FROM
    [TrackerNew].[dbo].[UnitCoreDetails] i
INNER JOIN
    Tracker.dbo.UnitCoreDetails s
ON
    i.[Serial] = s.[Serial]

Upvotes: 1

Related Questions