query error

Sam 0 Reputation points
2023-07-29T20:32:03.0366667+00:00

when i try run next query give me error

query

UPDATE dbo.SUB_VOUCHER SET ORA_DATE=(SELECT ORA_DATE FROM VOUCHER

WHERE SUB_VOUCHER.ENTRY_SERIAL=VOUCHER.ENTRY_SERIAL

error

Msg 102, Level 15, State 1, Line 2

Incorrect syntax near 'ENTRY_SERIAL'.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
42,119 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 120K Reputation points
    2023-07-30T07:11:35.8433333+00:00

    Try to add “)”:

    UPDATE dbo.SUB_VOUCHER 
    SET ORA_DATE=(SELECT ORA_DATE FROM VOUCHER
                  WHERE SUB_VOUCHER.ENTRY_SERIAL=VOUCHER.ENTRY_SERIAL)
    

    Probably you can also rewrite the statement using a JOIN.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.