When trying to copy the values of TableA to TableB in SQL 2008 environment, I’m trying to conditionally map some values to a new type and value.
For example, TableA has column Letters varchar(1) and stores letters of the alphabet, and I want to move these values to TableB in column Numbers int.
INSERT INTO TableB( SomeColumn1, Numbers, SomeColumn2 )
SELECT SomeColumn1,
LetterToNumber =
CASE Letters
WHEN 'A' THEN 1
...
WHEN 'Z' THEN 26
END,
SomeColumn2
FROM TableA
Is this the right way to go about doing this?
1 Answer