语法
PATINDEX('%pattern%', expression)
返回pattern字符串在表达式expression里第一次出现的位置,起始值从1开始计算,没有找到则返回0.
 
案例
select patindex('%ing%','Do one thing at a time, and do well.')
查询ing第一次出现的位置,结果为10
 
select patindex('%[a-e]%','Do one thing at a time, and do well.')
查询a-e字符第一次出现的位置,结果为6
 
select patindex('%[^a-e]%','Do one thing at a time, and do well.')
查询a-e之外的字符第一次出现的位置,结果为1
 
posted on 2018-04-13 13:44  明星程序员  阅读(164)  评论(0)    收藏  举报