Reputation: 113
I'm trying to remove the last character of a string if it is a '/' and the string could have multiple '/'s on the end.
For example, I have:
And want to get:
Upvotes: 0
Views: 180
Reputation: 11
Try something like this:
` SELECT REVERSE(SUBSTRING(reverse('c/string2//'),
PATINDEX('%[^/ ]%',reverse('c/string2//')),
DATALENGTH(reverse('c/string2//'))))`
Upvotes: 0
Reputation: 649
You can simply use:
SET @STR = 'b/bla///';
SELECT TRIM(TRAILING '/' FROM @STR);
Upvotes: 1