February 28, 2023 at 1:30 am
Hi SQL Team,
May I know how to get the 'ABC123_Clm R' string from the following string in SQL Server? Many thanks.
/Opr Rep/Clm R/ABC123_Clm R
February 28, 2023 at 9:46 am
This is just the same solution as I use in Extract only the filename from a file path; get the right most characters of the string, using the location of the first /
character in the reversed string. I also, however, concatenate an extra /
character to avoid an error, which I didn't do in the prior solution:
DECLARE @YourString varchar(50) = '/Opr Rep/Clm R/ABC123_Clm R';
SELECT @YourString AS FilePath,
RIGHT(@YourString, CHARINDEX('/', REVERSE(@YourString)+'/') -1) AS YourValue;
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
February 28, 2023 at 10:12 am
DECLARE @input_string VARCHAR(100) = '/Opr Rep/Clm R/ABC123_Clm R'
SELECT RIGHT(@input_string, CHARINDEX('/', REVERSE('/' + @input_string)) - 1) AS e_string
March 9, 2023 at 5:17 am
This was removed by the editor as SPAM
March 15, 2023 at 8:24 am
This was removed by the editor as SPAM
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply