jason
jason

Reputation: 7164

The multi-part identifier ould not be bound

I'm trying to update LICENCE in mydb.MATERIALS table with mydb_new.material table by joining them on MATERIALNO and MaterialID. I have this query below, it looks correct to me but I get this error :

The multi-part identifier "N.LICENCE" could not be bound.

UPDATE [mydb].[dbo].[MATERIALS]
 SET N.LICENCE= O.Licence
 FROM [mydb].[dbo].[MATERIALS] N 
 INNER JOIN [mydb_new].[dbo].[material] O 
 ON N.MATERIALNO = O.MaterialID
 WHERE N.LICENCE IS NOT NULL

Can you tell me how I can fix this? Thanks.

Upvotes: 1

Views: 63

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175586

You can use this UPDATE syntax:

UPDATE N
SET LICENCE= O.Licence
FROM [mydb].[dbo].[MATERIALS] N 
INNER JOIN [mydb_new].[dbo].[material] O 
   ON N.MATERIALNO = O.MaterialID
WHERE N.LICENCE IS NOT NULL

or:

UPDATE [mydb].[dbo].[MATERIALS]
SET LICENCE= O.Licence
FROM [mydb].[dbo].[MATERIALS] N 
INNER JOIN [mydb_new].[dbo].[material] O 
  ON N.MATERIALNO = O.MaterialID
WHERE N.LICENCE IS NOT NULL

Upvotes: 1

Related Questions