70651358
Knowledge Point one: CHARINDEX () syntax
CHARINDEX ( expression1 , expression2 [ , start_location ] )解析: expression1 必需 ---要查找的子字符串 expression2 必需 ---父字符串 start_location 可选 ---指定从父字符串开始查找的位置,默认位置从1开始
Knowledge Point two: The role of CHARINDEX ()
从expression2字符串中指定的位置处开始查找是否包含expression1字符串
Knowledge Point three: The return value of CHARINDEX ()
如果能够从expression2字符串中查找到expression1字符串则返回expression1在 expression2出现的位置;反之,返回0
Knowledge Point Four: example demonstration
1. Include:
select CHARINDEX(‘cd‘,‘abcdefg‘)
The result is: 3
2. Does not include:
select CHARINDEX(‘dc‘,‘abcdefg‘)
The result is: 0
Knowledge Point Four: The parameters of charindex () are case insensitive
Case:
select CHARINDEX(‘bCD‘,‘abcdefg‘)
The result is: 2
Parsing of the CHARINDEX function usage in SQL Server (searching for characters or strings in a paragraph-----returning expression1 where the expression2 appears; Conversely, return 0)