to search a pattern with in an expression and to get the position
use the following sql query
SELECT PATINDEX('%BC%','ABCD')
SELECT PATINDEX('%[s,S]erver%', 'Microsoft SQL Server SQL')
SELECT PATINDEX('%[1-9]163%', '12345A916303SQL')
SELECT PATINDEX('%[.]%', 'sample.xls')
if returns 0, no pattern found
if returns >0, pattern found
use the following sql query
SELECT PATINDEX('%BC%','ABCD')
SELECT PATINDEX('%[s,S]erver%', 'Microsoft SQL Server SQL')
SELECT PATINDEX('%[1-9]163%', '12345A916303SQL')
SELECT PATINDEX('%[.]%', 'sample.xls')
if returns 0, no pattern found
if returns >0, pattern found
No comments:
Post a Comment