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
Avatar of Arana (G.P.)
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;
Avatar of Grayson Hampton

ASKER

arana...

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

so you dont want to delete ConsultantID but rather remove the S and R characters from the field?
Avatar of Grayson Hampton

ASKER

@arana...

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Grayson Hampton

ASKER

@arana...

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

then one of the above examples will work for you
Avatar of Grayson Hampton

ASKER

Thank you arana for being extremely helpful and responsive.
SQL
SQL

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.

61K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo