I am testing contains method in store procedure. I would like to see data result like:
Example Result for John:
I don't want to use LIKE method. Can we use starts with or ends with (*) operator with parameters in SP?
CONTAINS(name,@name) // query is working
but if i can try like this:
CONTAINS(name, '"john" OR "john*"') // query is working
CONTAINS(name,'"@name" OR "@name*"') // query is not working
With parameters same query is not working in SP. Is it posibble to do this in SP?
Thanks,
With CONTAINS
, in order to pass a wildcard through with a variable, you need to make the wildcard a part of the variable.
The easiest way to do it within a stored procedure is adding a variable (or modifying your current variable).
For example,
DECLARE @nameX NVARCHAR(4000) = '"' + @name + '" OR "' + @name + '*"'
...
CONTAINS(name, @nameX)