I found a solution for finding underscore position with PATINDEX:
DECLARE @a VARCHAR(10) SET @a = '37_21' PRINT PATINDEX('%_%', @a) -- return 1 (false) PRINT PATINDEX('%!%', REPLACE(@a, '_', '!')) -- return 3 (correct)
Do you have any other ideas? How to escape the underscore?
regex sql-server tsql escaping sql-like
podosta May 14 '09 at 14:09 2009-05-14 14:09
source share