Declare @modCode varchar(3)
SET @modCOde = 'SOR';
UPDATE Doc_SalesOrder
SET OLD_SP.Num = NEW_SP.NewNum
FROM Doc_SalesOrder as OLD_SP
INNER JOIN
(
Select
Id,
dbo.ApplyModuleCode(@modCode,Num) as NewNum
From Doc_SalesOrder
Where Num not LIKE '%'+@modCOde+'%'
)NEW_SP ON OLD_SP.Id = NEW_SP.Id
When I run the query the error is:
The multi-part identifier “OLD_SP.Num” could not be bound.
Why?
Use
Or just simply drop the table prefix in the set statement target entirely. There is no ambiguity here.