How to detect a string in sql server in another string contains

select  CHARINDEX( '456' , '123456' )
 

SQL statements CHARINDEX function, another method for testing string a string contains:

A, CHARINDEX function introduction

1, Function: function returns the starting position of a character string or another string.

2、语法:CHARINDEX ( expression1 , expression2 [ , start_location ] ) 

3, Parameter Description: expression1 to expression2 to find the characters, start_location CHARINDEX function is to start looking for expression1 in expression2 position. 

4, the return value of the function: CHARINDEX function returns an integer, integer returned is looking at the position of the string in the string is looking. If no string CHARINDEX looking to find, then return 0

Second, for example: find the string 'abcdef' string 'cd', the result of operation 3, since C is the third character.

Guess you like

Origin www.cnblogs.com/xubao/p/11008146.html