You are viewing limited content. For full access, please sign in.

Question

Question

Workflow Custom Query: Syntax for using LIKE % with parameters

asked on June 25, 2014

 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!

0 0

Answer

SELECTED ANSWER
replied on June 25, 2014

Do you need the Unicode indicator?

 

LIKE ? should do it with ? defined without quotes and including the % at the end

2 0

Replies

replied on September 5, 2018

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 +%'.

1 0
replied on September 6, 2018

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.

0 0
replied on September 6, 2018

I don't know why but it's not working sad

0 0
replied on September 6, 2018

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.

0 0
replied on September 7, 2018

Hi Bert

It runs but does not return results, @hotelname is the name of the hotel,

Thanks for the help

0 0
replied on September 7, 2018

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?

0 0
replied on September 8, 2018

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.

0 0
replied on September 9, 2018 Show version history

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.

0 0
replied on September 11, 2018

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?

0 0
replied on September 11, 2018

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

0 0
replied on January 28, 2021

A common mistake is not including the '%' in your test value, if it is returning 0 rows affected lol

3 0
replied on April 19, 2021

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 + '%'

0 0
replied on June 26, 2014

Win! Thank you for the insight, Miruna! I will remember this method.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.