0

enter image description here

Here I need to match exact word but I am getting all results I used '%' + columnname + '%' in wildcard.

I am looking for exact word match doesn't matter it is beginning, in between and end of string.If i try to match 'America', I should be able to get 1st row as output.

  • Please always include the version of your server - answers can frequently depend on it! Edit the tags! – Vérace Mar 19 at 12:35
  • sql server 2016 – Tejas Mar 19 at 12:39
  • Match 'America' only - SELECT * FROM my_table WHERE Word LIKE '^America' AND Word Like 'America$'; Probably very inefficient! :-) – Vérace Mar 19 at 12:45
  • If you need to test for exact match use CHARINDEX. If you check for a word at the beginning, check it is 1, if not, simply check it is non-zero. – Akina Mar 19 at 12:56
  • String can be anything like 'The America USA Arizona' and I have 'America' , 'America USA', 'USA America' in my table so it should be match with 'America' only. – Tejas Mar 19 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.