samedi 25 avril 2015

SQL SERVER 2008 - Returning a portion of text using SUBSTRING AND CHARINDEX. Need to return all text UNTIL a specific char

I have a column called 'response' that contains lots of data about a person.

I'd like to only return the info after a specific string

But, using the method below I sometimes (when people have <100 IQ) get the | that comes directly after the required number..

I'd like any characters after the'PersonIQ=' but only before the pipe.

I'm not sure of the best way to achieve this.

Query speed is a concern and my idea of nested CASE is likely not the best solution.

Any advice appreciated. Thanks

substring(response,(charindex('PersonIQ=',response)+9),3)

Aucun commentaire:

Enregistrer un commentaire