Solved

TSQL Query

Posted on 2014-12-21
1
143 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Detach & Attach 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 article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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