Sql server parameterized query to match the exact word

时间:2018-06-20 05:02:59

标签: sql-server match prepared-statement parameterized-query exact-match

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.

0 个答案:

没有答案