Avatar of Grayson Hampton
Grayson Hampton asked on

Remove character from character string

How do I create a Case Statetment that deletes all ConsultantIDs that have an R and/or S?


ConsultantID
1001004
1001004R
1001004S
200311
200311R
200311S
Statistical PackagesR* T-SQLSQL

Avatar of undefined
Last Comment
Grayson Hampton

8/22/2022 - Mon
Arana (G.P.)

No need for a case statement, you could do that with a delete statement

delete from table where (charindex('S',ConsultantID)+charindex('R',ConsultantID))>0;
ASKER
Grayson Hampton

arana...

I would like to use this process in a Select statement that removes the characters.
Arana (G.P.)

so you dont want to delete ConsultantID but rather remove the S and R characters from the field?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
Grayson Hampton

@arana...

Yes, that is correct. I just want to delete S and R characters from the string.
ASKER CERTIFIED SOLUTION
Arana (G.P.)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Grayson Hampton

@arana...

No I do not have a specific reason to use Case.
Arana (G.P.)

then one of the above examples will work for you
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Grayson Hampton

Thank you arana for being extremely helpful and responsive.