update the column status based on other columns

Naresh y 146 Reputation points
2024-02-16T12:46:42.6866667+00:00

Hi team i have this table where the status are present in the table. i have three status columns Value_new/Value_old/IMNT_Status i need to update the IMT_Status whenever the value_new/Value_old column get updated., how do i update this IMT_Status for the given logic please share the logic input table User's image

Output table (desired o/p) User's image

SQL Server | Other
{count} votes

Answer accepted by question author
  1. Viorel 125.7K Reputation points
    2024-02-16T16:34:20.9366667+00:00

    Maybe like this:

    update MyTable
    set IMT_Status = coalesce(nullif(VALUE_NEW, ''), nullif(VALUE_OLD, ''))
    

0 additional answers

Sort by: Most helpful

Your answer

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