Is it possible to use only several starting characters of a field value as a base of case statement in a SQL Server stored procedure?
For example, I need to update a field in a table according to the first three characters in another field of the same table:
UPDATE Table1
SET Field1 = CASE
WHEN ??? = 'vl1' THEN '01'
WHEN ??? = 'vl2' THEN '02'
WHEN ??? = 'vl3' THEN '03'
'''''
END
How could I use the first three characters of a Field2 value instead of ??? ?
Use SUBSTRING
(I’ve switched to a simple CASE expression since that’s all we need here, and switched terminology too)