SQL obtain values between second and third forward slash

In SQL Server, I am trying to obtain the values between the second and third forward slash (/) character. The length of the numbers can vary so substring(column, 8, 10) wouldn’t work.


What I am trying to get in the current example is: 123456789

>Solution :

With 4 parts to your data as shown you can abuse the parsename function:

declare @string varchar(50) = '123/123/123456789/12';

select ParseName(Replace(@string,'/','.'),2);

Leave a Reply