localizar caractere em string

SQL Server

14/02/2005

Estou à procura de uma função no SQLServer que me retorne apenas (true ou false) se um caractere (ou conjunto de) está dentro de uma string. Algo do tipot tenho a string ´123456´, se eu procurar 5 me retorna true, se eu procurar 7 me retorna false.

Spasíba!!


Tommahawk

Tommahawk

Curtidas 0

Respostas

Marcus.magalhaes

Marcus.magalhaes

14/02/2005

Boa noite.

Este tipo de função não existe, o q vc pode fazer é testar com a função CHARINDEX(), se o valor for maior q 0 é pq existe.

Ex.:
Declare @variavelVarChar(10)

Set @variavel = ´123456´
Select CharIndex (´5´, @variavel, 1)
Select CharIndex (´7´, @variavel, 1)

Espero ter ajudado.

Att,


GOSTEI 0
Tommahawk

Tommahawk

14/02/2005

Sem dúvida, resolveu o problema. Grato mesmo.


GOSTEI 0
POSTAR