sql server - Find substring and then extract preceding substring -
This morning was beating my head this morning.
Select left (sub-string (notes, patindex ('% required' ', notes), 8000), patindex ('% required '', substitution (notes, patindex ('% required % ', Notes), 8000)) + 1) to .... Where .... Can anyone talk to me with the right direction or perhaps code assistance? thank you in advanced.
OK, it's ugly, but it works:
< code>; (SELECT * FROM (VALUES (Required 'Model 389448937594'), ('O, model 3453535345353453453 required'), ('I need demand 35435453')) A (string) Selection string, reverse (LEFT (data, CHARINDEX ('', data)) model (reverse selection (LEFT (string, PATINDEX ('% required%', string) -2) data, string from CTE) A The results are as follows:
one "one" ????? ?????? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? A ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? A ?????? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? A ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? A ???? a ?? a ???? a ???? a ???? a ???? a ???? ???? ???? ???? ???? ???? ???? ??? one one one ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? One One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? Line Line Line Line Model 389448937594 is required ??? 38 9 448937594 One ???? a???? Hey, model 3453535345353453453 is needed ??? 3453535345353453453 One ???? a???? I want 35435453 needed. 35435453 a ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? © One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ????
Comments
Post a Comment