March 15, 2011 at 10:34 am
Is there an escape character for the asterisk in SSRS? The asterisk is the wildcard character used in expressions, so I'm having troubles searching for the asterisk character in text for one of my fields.
March 15, 2011 at 10:39 am
Have you tried doubling it or using brakets around it?
March 15, 2011 at 10:48 am
Yes, I have tried both: [*] and "**".
I also tried preceding the asterisk with the following characters:
~`!@#$%^&*-_+=<>?/\|
So for example:
blah, blah, blah... Fields!MESSAGE_TEXT.Value like "\*"
No success.
March 15, 2011 at 10:55 am
Can't find anything usefull on google. I guess I'm searching for the wrong terms!
The only idea I have is to replace * with something silly like [star] and then use that in the other side of the equation.
March 16, 2011 at 12:39 pm
Your solution worked. In my expression, I did a replace() on the field and searched for the new character.
I'd like to keep this post open to see if anyone knows of an escape character in place of your workaround. This is the preferred solution. Thanks for your help!
March 17, 2011 at 8:55 am
Try this, it came from one of my favorite SQL books, SQL Queries for Mere Mortals (second edition). Use the ESCAPE option.
SELECT ProductName, ProductCode
FROM Products
WHERE ProductCode like 'G00\*' ESCAPE '\'
March 17, 2011 at 8:58 am
Jacque.Murrell (3/17/2011)
Try this, it came from one of my favorite SQL books, SQL Queries for Mere Mortals (second edition). Use the ESCAPE option.SELECT ProductName, ProductCode
FROM Products
WHERE ProductCode like 'G00\*' ESCAPE '\'
That's an escape from a query. He wants to escape in a table (or matrix) within the report. That's long after the query has been processed!
March 17, 2011 at 12:19 pm
Road Kill (3/15/2011)
Is there an escape character for the asterisk in SSRS? The asterisk is the wildcard character used in expressions, so I'm having troubles searching for the asterisk character in text for one of my fields.
When you want to use a wildcard character as a literal value within a string constant in an SSRS expression involving the LIKE operator ("escaping" it from its usual role as a wildcard character), enclose it with square brackets.
For example, this expression:
=IIf([string] like "*", "Win",'Fail")
returns "Win" for the strings "*", "x", "x*", "*y", and "x*y" because the asterisk operates as a wildcard.
This expression, though:
=IIf[string] like "[*]", "Win",'Fail")
returns "Win" only for the string "*" because you are now searching for a literal asterisk character.
This expression:
=IIf([string] like "[*]*", "Win",'Fail")
returns "Win" for the strings "*" and "*y",
while this expression:
=IIf([string] like "*[*]", "Win",'Fail")
returns "Win" for the strings "*" and "x*"
and this expression:
=IIf([string] like "*[*]*", "Win",'Fail")
returns "Win" for the strings "*", "x*", "*y", and "x*y", but not for "x".
Since you can't perform pattern matching using the "=" operator in Visual Basic-based code, don't use the square brackets when using characters like "*" and "?" in expressions using "=".
Jason Wolfkill
March 18, 2011 at 1:30 pm
Oh heck yeah! That's it!
I tried "[*]" but actually needed "*[*]*". Thanks wolfkillj!
March 18, 2011 at 2:02 pm
Oh crap, I know I should have checked that one myself... never take the word of someone online when you think they're wrong! :w00t:
Looks like we misunderstood each other on my first post :hehe:.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply