I am searching for a keyword using SQL server and Regex Functionality.
we have a data like leaky gas, leaked gas, and leaking gas.
SELECT [Text field]
FROM [Global database]
text field is like '%leak[a-z]{1,3} gas%'
I am searching for a keyword using SQL server and Regex Functionality.
we have a data like leaky gas, leaked gas, and leaking gas.
SELECT [Text field]
FROM [Global database]
text field is like '%leak[a-z]{1,3} gas%'
SQL Server does not support regular expressions (unless you add your own UDF). It does however extend the LIKE functionality for some basic wildcards.
You can do what you want as:
where field like '%leak[a-z] gas%' or
field like '%leak[a-z][a-z] gas%' or
field like '%leak[a-z][a-z][a-z] gas%'
You can create a regex CLR that can be used in SQL.