escape character

A free Management Studio add-in to search for SQL in your databases

Moderator: dom.smith

escape character

Postby james.elmer@live.com » Fri May 09, 2014 4:56 pm

I am trying to search for text that actually contains a % character in TSQL code.

For example, I have a product named 'ProductName' and SQL code that looks for it by this query:

WHERE product LIKE 'ProductN%'

I'd like Sql Search to limit the results by including the %

Sql Search text: 'ProductN%'

Is it possible to escape the % so sql search matches the % character?
James
james.elmer@live.com
 
Posts: 1
Joined: Fri May 09, 2014 4:43 pm
Location: State College, PA

Postby dom.smith » Fri May 16, 2014 3:33 pm

Hi,

As you've probably realized, when you type a '%' character, SQL Search always interprets it as a wildcard, including in 'Exact Match' mode.

However, I'm not sure why this would be a problem for you, because wildcard '%' will match the literal '%' character.

So, when you search for 'ProductN%', that should give the result you want (although there may also be other results for 'ProductNumber', for example, since this would also match 'ProductN%').

I hope that makes sense. If it isn't working as I've described, please let me know here, including which version of SSMS and Operating System you are using.

Thanks,

Dom.
Dominic Smith,
Project Manager,
Red Gate Software.
dom.smith
 
Posts: 98
Joined: Thu Jun 03, 2010 5:54 pm
Location: Cambridge, UK

There are cases when we need to search for '%'

Postby benik9 » Tue May 27, 2014 2:43 pm

In our objects, we use a code value to describe a logic. For example, when 'A%' then aaa when 'B%' then bbb.

I wish redgate search can search for a '%' character.
benik9
 
Posts: 3
Joined: Tue Jul 09, 2013 5:07 pm


Return to SQL Search 2

Who is online

Users browsing this forum: No registered users and 0 guests