Home > database >  Intercept SQL string
Intercept SQL string

Time:01-20

Such as a list of to intercept [] in the middle of the string, could you tell me how to write your SQL

CodePudding user response:

 
DECLARE @ A VARCHAR (100)

The SET @ A='[123 * 456] B

SELECT SUBSTRING (@ A, CHARINDEX (' [' @ A) + 1, CHARINDEX ('] '@ A) - CHARINDEX ('/', @ A) - 1)

CodePudding user response:

If this is the [] up data, the direct drop directly replace [and] it is ok to
 DECLARE @ STR NVARCHAR (200)='[1.5 cm * 500 c]' 
SELECT the REPLACE (REPLACE (@ STR, '[',' '), '] ', ')


If not you need to get the location of the [and], and then to intercept
  • Related