Re: Using '_' as a character and not as a wildcard

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Daniel Crichton (msnews_at_worldofspack.co.uk)
Date: 12/21/04


Date: Tue, 21 Dec 2004 09:34:57 -0000


"Steen Persson" <SPE@REMOVEdatea.dk> wrote in message
news:%23L5nV0z5EHA.2124@TK2MSFTNGP15.phx.gbl...
> Hi
>
>
> I'm trying to do a script that can automatically backup the databases on
> our
> Datawarehouse server. The databases have been prefixed with 'pl_'.
>
> When I run -
>
> SELECT Catalog_Name
> FROM Information_Schema.Schemata
> WHERE Catalog_Name LIKE 'pl_%'
>
> - it finds all my databases that have been prfixed with 'pl_' but also
> some
> called e.g. 'plan....'.
> I can see in BOL that '_' is seen as a wildcard that can substitute any
> single character, but how do I tell my query to use '_' as a part of the
> name and not as a wildcard?

You can add the ESCAPE clause to tell the query processor to treat the
character after the defined escape character as a literal, ie

SELECT Catalog_Name
       FROM Information_Schema.Schemata
WHERE Catalog_Name LIKE 'pl!_%'
ESCAPE '!'

The ! is the escape character in this case, so the _ is interpreted as a
literal character rather than a wildcard.

Dan



Relevant Pages

  • RE: Find method failure in Word COM Addin
    ... I just wonder why you need find such a long string. ... Also have you tried to use widecard match. ... Enter a wildcard character in the Find What box. ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: How to extract email addresses from a word document or htm web page?
    ... an escape character - here '\' whenever such a special character is used. ... Check the help for Wildcard ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Re: Help needed! Complicated Find/Replace requirement
    ... This has extensive ways to construct wildcard searches. ... backslash before the character. ... At least n occurrences of the previous character or expression ... Word will find "Newton Christie" and replace it with "Christie ...
    (microsoft.public.word.general)
  • RE: Find method failure in Word COM Addin
    ... A wildcard search will not work in this case. ... specific paragraph of text into the document. ... Enter a wildcard character in the Find What box. ... At least n occurrences of the previous character or expression ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: Wild card characters are not working as expected in MS word 2007
    ... Space is a character so Word is correctly matching your pattern. ... Case sensitivity is not relevant to wildcard searches - that is why the option is unavailable. ... This post is a suggestion for Microsoft, ...
    (microsoft.public.word.application.errors)