sql server replace query?

  • I have a column in sql server table in which there are integer values, now i want to replace a range e.g values> 50 with a string 'good' and values<50 replace with 'bad' in only one column in that table, I have tried this

    SELECT t.ColA, CASE WHEN t.ColA >= 50 THEN 'Normal value' WHEN t.ColA < 50 THEN 'abnormal value' END

    FROM MySchema.MyTable AS t

    but it only selects, not replaced the column values>50 with 'normal value' string. any help please?

  • Maybe you should try an UPDATE statement instead?

    Also make sure ColA is a varchar column, otherwise you won't be able to store the string values.

    (and convert ColA to int before you compare it with 50)

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply