Solved

TSQL Query

Posted on 2014-12-21
1
134 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

11 Experts available now in Live!

Get 1:1 Help Now