Solved

TSQL Query

Posted on 2014-12-21
1
136 Views
Last Modified: 2014-12-22
a question for a where statement in TSQL, what does escape '\\ mean ??

where A.PRODID NOT LIKE '%\-%' escape '\'  AND
0
Comment
Question by:AXISHK
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 40512420
There are some characters in the Sql pattern matching scenario that are special.

A percent sign for example is a wildcard that matches any string of 0 or more characters.

So how do you handle it when you need to search specifically for a '%' ?

This is where the escape keyword comes in.  You can tell the database that any time you see the escape character in the pattern followed by a wildcard character then that wildcats should be treated as a regular character instead.

The hyphen/dash character doesn't have any special meaning as far as I can recall so in your example it is looking for any string with a dash in it.  The percent signs are wild cards and since the backslash is the escape character it says that the dash should be treated exactly as a dash and not perform anything special.

Have a read of the books online article on using LIKE with ESCAPE.

Http://msdn.microsoft.com/en-us/library/ms179859.aspx
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now