Crysis Hhtht
Crysis Hhtht

Reputation: 131

SQL multi-part identifier error on Update query

Could anyone point me out the issue in below update query?

enter image description here

Upvotes: 0

Views: 52

Answers (2)

theLaw
theLaw

Reputation: 1291

The other column is in another table. You must join your table like this (is an example between two table, I can't give you the exact query since I don't know how is your schema):

UPDATE A SET
  A.COLUMN1 = 1
FROM TABLE1 AS A
JOIN TABLEB AS B ON A.ID = B.ID

Upvotes: 1

Lukasz Szozda
Lukasz Szozda

Reputation: 175686

In order to refer to a table you have to use use it in FROM or JOIN clause:

UPDATE dbo.SALES_ORD_HDR
SET X_PickingSlip_Printed = 1
WHERE SEQNO IN (SELECT HEADER_SOURCE_SEQ FROM dbo.SALESORDHIST);
                                         -- here you are refering table

alternatively using correlated subquery:

UPDATE dbo.SALES_ORD_HDR
SET X_PickingSlip_Printed = 1
WHERE EXISTS (SELECT 1 FROM dbo.SALESORDHIST
              WHERE dbo.SALES_ORD_HDR.SEQNO = dbo.SALESORDHIST.HEADER_SOURCE_SEQ);

Upvotes: 1

Related Questions