Question

I have this UPDATE statement:

UPDATE BLDG SET
    BLDG.BLOC1 = T.BLOC1,
    BLDG.BLOC2 = T.BLOC2,
    BLDG.BLOC3 = T.BLOC3
FROM BLDG B
INNER JOIN
    (SELECT * FROM dbo.INVENTORIZE(B.B_ID)) T
ON B.B_ID = T.B_ID

which uses a simple function that - run separately - returns:

B_ID   BLOC1   BLOC2   BLOC3
-----------------------------
1      2.00    3.00    NULL

The above update statement returns an error "The multi-part identifier "B.B_ID" could not be bound." What am I doing wrong?

Was it helpful?

Solution

UPDATE B SET
    BLOC1 = T.BLOC1,
    BLOC2 = T.BLOC2,
    BLOC3 = T.BLOC3
FROM dbo.BLDG B
CROSS APPLY dbo.INVENTORIZE(B.B_ID) AS T;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top