September 24, 2013 at 2:42 pm
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?
September 24, 2013 at 2:49 pm
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
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy