MidText
Extracts a string from another string based on adjoining strings
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.MidText ( @Text, @Start, @End, @Index )
Name | Type | Description |
---|---|---|
@Text | nvarchar(MAX) |
String expression to extract from |
@Start | nvarchar(MAX) |
String preceding the substring to be retrieved |
@End | nvarchar(MAX) |
String proceeding the substring to be retrieved |
@Index | smallint | Integer value specifying the instance of a substring between Start and End |
nvarchar(MAX)
Retrieving text surrounded by double brackets:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
DECLARE @Text nvarchar(MAX) DECLARE @Start nvarchar(MAX) DECLARE @End nvarchar(MAX) DECLARE @Index int SET @Text = '[[some]] of these [[words]] are in [[double brackets]]' SET @Start = '[[' SET @End = ']]' SET @Index = 3 SELECT SQLHTTP.net.MidText(@Text, @Start, @End, @Index) |
1 2 3 4 5 |
------------------- double brackets |