Solved

TSQL Query

Posted on 2014-12-21
1
144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 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