How to use parameter with LIKE in Sql Server Compact Edition

前端 未结 5 1414
后悔当初
后悔当初 2020-12-17 19:07

I\'m trying to parameterise a search query that uses the LIKE keyword with a wildcard. The original sql has dynamic sql like this:

\"AND JOB_POSTCODE LIKE \'         


        
5条回答
  •  星月不相逢
    2020-12-17 19:35

    Using:

    "AND JOB_POSTCODE LIKE '" + isPostCode + "%' "
    

    ...means that the string is constructed before being tacked onto the dynamic SQL. This is so that you don't have to specify the parameter in the parameter list for sp_executesql/EXEC, while this:

    "AND JOB_POSTCODE LIKE @postcode + '%' "
    

    ...does. Please post more of the query.

提交回复
热议问题