79447778

Date: 2025-02-18 09:49:06
Score: 2.5
Natty:
Report link

SELECT CASE -- Ensure there are at least two semicolons WHEN LEN(@string) - LEN(REPLACE(@string, ';', '')) >= 2 THEN -- Extract the part between the second-last and last semicolon SUBSTRING( @string, LEN(@string) - CHARINDEX(';', REVERSE(@string), CHARINDEX(';', REVERSE(@string)) + 1) + 2, CHARINDEX(';', REVERSE(@string), CHARINDEX(';', REVERSE(@string)) + 1) - CHARINDEX(';', REVERSE(@string)) - 1 ) ELSE NULL END AS SecondGroupFromRight

Reasons:
  • No code block (0.5):
  • User mentioned (1): @string
  • Low reputation (1):
Posted by: Pandav Kishan