Cari Blog Ini

16 Oktober 2012

How To Get String Between Two Delimiters using TSQL

-----code:start--------------------------------

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 ) )
)

-----code:end--------------------------------

Results Messages:
This is a sample string


Source:
http://www.sqlservercentral.com/scripts/91995/
Article : Get String between two delimiters By Harsha Majety