Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
WHEN SUBSTRING([Remarks], CHARINDEX('-', [Remarks], CHARINDEX('-', [Remarks]) + 1) + 1, LEN([Remarks])) LIKE '%CLP' THEN


What I have tried:

I've tried changing my query to
WHEN SUBSTRING([Remarks], CHARINDEX('-', [Remarks], CHARINDEX('-', [Remarks]) + 1) + 1, LEN([Remarks])) ='CLP' THEN
Posted
Updated 18-Apr-23 23:02pm
Comments
Koen Matthijs 2023 19-Apr-23 7:32am    
Can you post more of the query? I don't get an error when I try you're part of the CASE statement in any example at my side

1 solution

You're checking to see whether the substring from the second "-" to the end of the string ends with "CLP".

If the string contains one "-" character, or no "-" characters, you take the entire string.

Therefore, your test is equivalent to:
SQL
WHEN [Remarks] LIKE '%CLP'
 
Share this answer
 
v2
Comments
kadefgahnna 23-Apr-23 20:41pm    
Thanks for the answer @richard but I still got an error using LIKE keyword. Error message: Incorrect syntax near the keyword 'LIKE'.
Richard Deeming 24-Apr-23 3:04am    
Then there's something else wrong with your query. You haven't shown enough of the query to tell you what the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900