How to match whole word in SQL.
We very frequently face the requirement to match an entire word, while developing the website/application.
This problem can be very easily handled by Microsoft SQL query.
For example when you search for “ram”, if you use “%ram%” it will also match “programme”.
To resolve this, we can use regular expression like syntax in SQL.
The below query will only return the title having “ram” and not “programme”.
select title from article where ‘ ‘+title like ‘%[ ]ram[ ]%’
Additionally we also can provide extra characters to match after word like
select title from article where ‘ ‘+title like ‘%[ -_]ram[ .-_]%’
Enjoy working with SQL.More