I have the following string values in a column within a SQL server database table:
CS-NO2-T6082 BROWN,STORAGE
CS-NO2-T6082 BROWN
CS-CT2N64045,POW REC X 2,ROCKER
CONSOLE,CS-CT2N74045,POW REC X 2
CS
CS,MAN REC
CS-T6082,POW REC X 2
CS-CT12N1176
CS-NO2-T6082 BROWN,SQUARE
CS-CT12N1176
CS-2T1176 GREY
I am trying to retrieve values only when it is preceded by 'CS' but there are multiple cases as shown in above examples. 'CS' may appear on it's own or with number separated by '-' and then a color separated by a space. It can be in the beginning of a string, in the middle or at the end. I want to first check if there is only one value in the column by checking for a comma, if there is only one value and it contains the word 'CS' then it looks simple. But when there are multiple values on either side of the string interested in then it becomes a problem.
I will appreciate any suggestions or solutions in sql server please.
The result should look like:
CS-NO2-T6082 BROWN
CS-NO2-T6082 BROWN
CS-CT2N64045
CS-CT2N74045
CS
CS
CS-T6082
CS-CT12N1176
CS-NO2-T6082 BROWN
CS-CT12N1176
CS-2T1176 GREY
Thanks.