Andrew
asked on
STUFF function - proper use to update column?
Hello,
I have been struggling to figure out how to properly use the STUFF function to update a column's values. If column's first char is "D" then update it to begin with "DC" instead.
column value example: D5001-T04077G1S6
column value after update: DC5001-T04077G1S6
my latest attempt:
I have been struggling to figure out how to properly use the STUFF function to update a column's values. If column's first char is "D" then update it to begin with "DC" instead.
column value example: D5001-T04077G1S6
column value after update: DC5001-T04077G1S6
my latest attempt:
SELECT CASE
WHEN
LEFT(LabelName,1) = 'D'
THEN
SET LabelName = STUFF(LabelName, 1, 1, 'DC')
ELSE
LabelName
END
FROM
[Cassavas]
WHERE
IdOriginal = '91123'
ASKER
That updated the record to this: DC001-T04077G1S instead of this: DC5001-T04077G1S6
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
Open in new window