Technical Article

Get String between two delimiters

,

Delimiter in the sample string i chose is # .

Script gets string between two #s.

DECLARE @sampleString VARCHAR(1000) = '#This is a sample string# between two delimiters'DECLARE @sampleString VARCHAR(1000) = '#This is a sample string# between two delimiters'
SELECT Substring(@sampleString, ( Patindex('%#%', @sampleString) + 1 ), ( ( Len(@sampleString) - ( Patindex('%#%', Reverse(@sampleString)) ) + 1 ) - ( Patindex('%#%', @sampleString) + 1 ) ))

Rate

3 (7)

You rated this post out of 5. Change rating

Share

Share

Rate

3 (7)

You rated this post out of 5. Change rating