• But there is no need to add a from clause as it was working fine.

    See the code below:

    --my table payment_details structure is

    DECLARE @payment_details TABLE

    (

    payment_id INT PRIMARY KEY CLUSTERED NOT NULL

    ,payment_code INT NULL

    );

    INSERT INTO @payment_details (payment_id)

    VALUES (1),(2),(3),(4)

    UPDATE @payment_details

    SET payment_code =payment_id

    WHERE payment_code IS NULL

    SELECT

    *

    FROM @payment_details

    Result:

    payment_id payment_code

    ----------- ------------

    1 1

    2 2

    3 3

    4 4

    Kindly, share the exact error..