I'm trying to find a string in a main string and remove it.
Example:
@Main_text = 'some text some text... // remove text remove text \\ some text some text'
What I want is to remove the following text:
// remove string remove string \\ of the main text
What I tried
declare @main_text varchar(255) = 'some text some text... // remove text remove text \\ some text some text'
SELECT STUFF(@main_text,
charindex('//', @main_text),
charindex('\\', @main_text) ,
'');
This partly works. it removes the searched text but also remove the end of the text.