I need to trim string between occurrences of character '-'. string is 'location-servername-DB-table-location-servername-ID' and end result needs to be substring between forth and fifth(last) '-'
example:
DECLARE @String NVARCHAR(max) ='SERVER-NAME1-DB-TABLE-SERVER-NAME2-NUMBER'
SELECT
substring(right(@String, charindex('-', @String, charindex('-', @String)+3)-5), 1, (len(right( @String, charindex('-', @String, charindex('-', @String)+1)+1)) -10)) [SUBSCRIBER SERVER NAME]