Reputation: 975
I am trying to perform some data conversion on a table. I am trying to take a value (string) from one table and make give it a corresponding numeric value (int) in the new table.
For instance:
Operational = 1
Needs Repair = 2
etc.
I can find examples for casting and parsing values into new data types however I can not find examples on how to change the actual value to something else.
Upvotes: 1
Views: 34
Reputation: 6683
You need to use CASE statement
select
case yourfield
when 'Operational' then 1
when 'needs Repair' then 2
.... and so on....
end AS yourfield
from yourtable
Upvotes: 2