Can you please tell me how to correctly use the LIKE operator with a parameter.
I have tried it the following ways to no avail:
LIKE N '?%'
LIKE N ? + '%'
LIKE N '%' + ? + '%'
Thanks you in advance!
Can you please tell me how to correctly use the LIKE operator with a parameter.
I have tried it the following ways to no avail:
LIKE N '?%'
LIKE N ? + '%'
LIKE N '%' + ? + '%'
Thanks you in advance!
Do you need the Unicode indicator?
LIKE ? should do it with ? defined without quotes and including the % at the end
I have a similar problem but I am using direct connection instead of ODBC so I can not use "?", I have tried using '% @ token%' but it does not bring anything, if I try the same query in the SQL console it works, I also try '% + @ token +%'.
This works for me without any problems
Make sure that your Parameter name starts with an "@"
Make sure that in the Parameter value, you follow the token name with a "%"
Do not include single quotes or percent symbols in the token text.
I don't know why but it's not working
Does it error or just not return results?
Is the @hotelname the name of the hotel or the ID? It looks like you're Parameter value is passing in an ID rather than a name.
Hi Bert
It runs but does not return results, @hotelname is the name of the hotel,
Thanks for the help
The name of your token that is providing the Hotel name (SeconectaaBDdeSmart_HotelHID) appears to provide an ID rather than a name. Have you put in a "Track Token" activity to see the value that is in the SeconectaaBDdeSmart_HotelHID token?
If, place a "Track Token", the variable brings the name not the ID. At the end, as the table had less than 20 records, add the column of code and consult based on a variable that is the code of the hotel.
Thank you very much for your time Bert, this has happened to me on other occasions and I do not understand why sometimes it works well and sometimes it does not.
When I do not get the expected results, I look at the value that is in the WF token
Then I open SQL Management Studio and run the same query
and replace the variable with the actual token value
This helps me narrow down if the problem is the query, the parameter, or maybe the workflow connection or syntax.
You seemed to initially indicate that you want to look for "contains value" but your query parameter setup only looks for "starts with". Is that intended?
Thanks MIruna and Bert, Both ways work for me because the main issue is that the data we pass to the request is shorter than the one on the table.
But it does not work for me in any way
A common mistake is not including the '%' in your test value, if it is returning 0 rows affected lol
I have been having difficulties with this concept but was able to get the following to work. Not sure if it's the right way to do it but it's working for my process! Hopefully it helps someone :)
SELECT * FROM Table WHERE Column1 LIKE '%' + @parameter + '%'
Win! Thank you for the insight, Miruna! I will remember this method.