0

I am using the following sql:

 String realname;
 String fakename;

 String sql = "UPDATE PERSON SET NAME = CAST(REPLACE(CAST(NAME as nvarchar(max)), ? , ?) as ntext)";

        PreparedStatement preparedstmt = conn.prepareStatement(sql);
        preparedstmt.setString(1, realname);
        preparedstmt.setString(2, fakename);

realname and fakenames are from config files. I don't know their values during coding.

I want to match the exact word.

like '% word %'

example:

I want to match only Tom , not Tommy.

Please help.

Ilak
  • 158
  • 3
  • 13
  • Read the accepted answer [here](https://stackoverflow.com/questions/5444300/search-for-whole-word-match-with-sql-server-like-pattern) for your actual question. But I don't see what that has to do with an update. – Tim Biegeleisen Jun 20 '18 at 05:12
  • Your best bet would be using a decent regex function (which SQL Server doesn't have). Variations might include replacing your word with additional leading or trailing spaces or punctuation marks. – EzLo Jun 20 '18 at 06:30
  • '.' + column + '.' LIKE '%[^a-z]pit[^a-z]%' The problem is I don't want to embed the string like pit. I only have a placeholder there. I don't have a word like pit that I am looking for. – Ilak Jun 20 '18 at 06:55
  • I want something like this: – Ilak Jun 20 '18 at 06:58

0 Answers0