语法
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
Sybase PATINDEX
原文:https://www.cnblogs.com/ambiguous/p/8819866.html