T-SQL and the WHERE LIKE %Parameter% clause

后端 未结 3 1776
后悔当初
后悔当初 2020-11-30 06:28

I was trying to write a statement which uses the WHERE LIKE \'%text%\' clause, but I am not receiving results when I try to use a parameter for the text. For example, this

3条回答
  •  臣服心动
    2020-11-30 06:52

    It should be:

    ...
    WHERE LastName LIKE '%' + @LastName + '%';
    

    Instead of:

    ...
    WHERE LastName LIKE '%@LastName%'
    

提交回复
热议问题