IndexOf function in T-SQL

前端 未结 4 1152
广开言路
广开言路 2020-12-09 00:43

Given an email address column, I need to find the position of the @ sign for substringing.

What is the indexof function, for strings in T-SQL?

L

4条回答
  •  甜味超标
    2020-12-09 00:56

    You can use either CHARINDEX or PATINDEX to return the starting position of the specified expression in a character string.

    CHARINDEX('bar', 'foobar') == 4
    PATINDEX('%bar%', 'foobar') == 4
    

    Mind that you need to use the wildcards in PATINDEX on either side.

提交回复
热议问题